Pyjnius autoclass method can't find any 'android.X' classes

136 Views Asked by At

I'm just trying to do a simple app to lock android screen, but using Python. For that I try Pyjnius.

When I try to get any class within 'android' package, like this:

DevicePolicyManager = autoclass('android.admin.DevicePolicyManager')

it just doesn't find and returns:

jnius.check_exception jnius.JavaException: JVM exception occurred: android/net/Uri java.lang.NoClassDefFoundError

However, it does find the classes within 'java' package and returns the correct class when I do something like:

teste = autoclass('java.security.AccessController')

Could it be something wrong with the instalation of java? Or Android SDK? I'm using VS Code, running in Windows 10 with WSL. I've set path for java in env variables like this:

System Vars:
%ProgramFiles%\Java\jdk-18.0.2.1\bin

User Vars:
JAVA_HOME=%ProgramFiles%\Java\jdk-18.0.2.1\bin
PATH=%ProgramFiles%\Java\jdk-18.0.2.1\bin\server;%ProgramFiles(x86)%\Java\jre1.8.0_341\bin;

Hope anyone can help me on that!

0

There are 0 best solutions below