I am making a simple python script that utilizes openai and jnius(or as it's now known 'pyjnius) libraries with the intention of integrating with android studio. I have the mainactivity.xml and everything working perfectly, internet access setup in the manifest etc. My only issue is when asking ChatGPT a question (in the emulator while running the app) I am getting a response in the app UI that the module Jnius is not found. I have pyjnius installed on my dev machine and this shows in visual studio codes interpreter and the like. I have tried doing a pip install in the build.gradle but android studio wont install jnius that way (however it works perfectly for the openai library).
e.g.
python{
pip{
install "jnius"
}
}
In my script.py in src/main/python I have this for my imports:
from jnius import autoclass
import openai
Am I simply using Jnius(pyjnius) incorrectly? Or is it not compatible for use with chaquopy/android studio?
Pyjnius is not compatible with Chaquopy. You should use Chaquopy's own API instead.
For simple cases, you may be able to simply replace from jnius import autoclass
with from java import jclass as autoclass
.