Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jython isn't working on Android, due to the absence of java.lang.ClassValue #329

Open
z-zeechung opened this issue May 3, 2024 · 1 comment

Comments

@z-zeechung
Copy link

z-zeechung commented May 3, 2024

Below is the error report. This might be resolved by manually implementing ClassValue.java. I'm not sure if there are still more problems to come, and I wish to know whether Jython is designed to run on Android.

E/AndroidRuntime: FATAL EXCEPTION: Thread-4
    Process: com.zeechung.cartark, PID: 29333
    java.lang.NoClassDefFoundError: Failed resolution of: Ljava/lang/ClassValue;
        at org.python.core.PyType.fromClass(PyType.java:2137)
        at org.python.core.PyObject.<init>(PyObject.java:85)
        at org.python.core.PyBuiltinCallable.<init>(PyBuiltinCallable.java:22)
        at org.python.core.PyBuiltinMethod.<init>(PyBuiltinMethod.java:16)
        at org.python.core.PyBuiltinMethod.<init>(PyBuiltinMethod.java:21)
        at org.python.core.PyType$type___init___exposer.<init>(Unknown Source:0)
        at org.python.core.PyType$PyExposer.<init>(Unknown Source:16)
        at org.python.core.PyType.<clinit>(Unknown Source:2)
        at org.python.core.PyType.fromClass(PyType.java:2137)
        at org.python.core.PyObject.<init>(PyObject.java:85)
        at org.python.core.PyBuiltinCallable.<init>(PyBuiltinCallable.java:22)
        at org.python.core.PyBuiltinMethod.<init>(PyBuiltinMethod.java:16)
        at org.python.core.PyBuiltinMethodNarrow.<init>(PyBuiltinMethodNarrow.java:23)
        at org.python.core.PyDataDescr$getset_descriptor___get___exposer.<init>(Unknown Source:2)
        at org.python.core.PyDataDescr$PyExposer.<init>(Unknown Source:15)
        at org.python.core.PyDataDescr.<clinit>(Unknown Source:2)
        at org.python.core.PyBuiltinCallable$PyExposer.<init>(Unknown Source:14)
        at org.python.core.PyBuiltinCallable.<clinit>(Unknown Source:2)
        at org.python.core.PyObject$PyExposer.<init>(Unknown Source:13)
        at org.python.core.PyObject.<clinit>(Unknown Source:2)
        at org.python.core.PyNone.getInstance(PyNone.java:28)
        at org.python.core.Py.<clinit>(Py.java:62)
        at org.python.core.Py.newStringMap(Py.java:850)
        at org.python.util.PythonInterpreter.<init>(PythonInterpreter.java:99)
        at org.python.util.PythonInterpreter.<init>(PythonInterpreter.java:93)
        at org.python.util.PythonInterpreter.<init>(PythonInterpreter.java:70)
        at com.zeechung.cartark.misc.ScriptEnv.<clinit>(ScriptEnv.java:27)
        at com.zeechung.cartark.misc.ScriptEnv.python(ScriptEnv.java:31)
        at com.zeechung.cartark.llm.QianfanLLM.lambda$static$0(QianfanLLM.java:105)
        at com.zeechung.cartark.llm.QianfanLLM$$ExternalSyntheticLambda0.run(Unknown Source:0)
        at java.lang.Thread.run(Thread.java:923)
     Caused by: java.lang.ClassNotFoundException: Didn't find class "java.lang.ClassValue" on path: DexPathList[[dex file "/data/data/com.zeechung.cartark/code_cache/.overlay/base.apk/classes3.dex", dex file "/data/data/com.zeechung.cartark/code_cache/.overlay/base.apk/classes4.dex", dex file "/data/data/com.zeechung.cartark/code_cache/.overlay/base.apk/classes5.dex", dex file "/data/data/com.zeechung.cartark/code_cache/.overlay/base.apk/classes6.dex", dex file "/data/data/com.zeechung.cartark/code_cache/.overlay/base.apk/classes7.dex", dex file "/data/data/com.zeechung.cartark/code_cache/.overlay/base.apk/classes8.dex", dex file "/data/data/com.zeechung.cartark/code_cache/.overlay/base.apk/classes9.dex", zip file "/data/app/~~rD_2M-vJ5IJ-P-zaqxA_xg==/com.zeechung.cartark-N7ZAG7XuR3xxQQYo2CQldA==/base.apk"],nativeLibraryDirectories=[/data/app/~~rD_2M-vJ5IJ-P-zaqxA_xg==/com.zeechung.cartark-N7ZAG7XuR3xxQQYo2CQldA==/lib/x86, /system/lib, /system_ext/lib]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:207)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
        at org.python.core.PyType.fromClass(PyType.java:2137) 
        at org.python.core.PyObject.<init>(PyObject.java:85) 
        at org.python.core.PyBuiltinCallable.<init>(PyBuiltinCallable.java:22) 
        at org.python.core.PyBuiltinMethod.<init>(PyBuiltinMethod.java:16) 
        at org.python.core.PyBuiltinMethod.<init>(PyBuiltinMethod.java:21) 
        at org.python.core.PyType$type___init___exposer.<init>(Unknown Source:0) 
        at org.python.core.PyType$PyExposer.<init>(Unknown Source:16) 
        at org.python.core.PyType.<clinit>(Unknown Source:2) 
        at org.python.core.PyType.fromClass(PyType.java:2137) 
        at org.python.core.PyObject.<init>(PyObject.java:85) 
        at org.python.core.PyBuiltinCallable.<init>(PyBuiltinCallable.java:22) 
        at org.python.core.PyBuiltinMethod.<init>(PyBuiltinMethod.java:16) 
        at org.python.core.PyBuiltinMethodNarrow.<init>(PyBuiltinMethodNarrow.java:23) 
        at org.python.core.PyDataDescr$getset_descriptor___get___exposer.<init>(Unknown Source:2) 
        at org.python.core.PyDataDescr$PyExposer.<init>(Unknown Source:15) 
        at org.python.core.PyDataDescr.<clinit>(Unknown Source:2) 
        at org.python.core.PyBuiltinCallable$PyExposer.<init>(Unknown Source:14) 
        at org.python.core.PyBuiltinCallable.<clinit>(Unknown Source:2) 
        at org.python.core.PyObject$PyExposer.<init>(Unknown Source:13) 
        at org.python.core.PyObject.<clinit>(Unknown Source:2) 
        at org.python.core.PyNone.getInstance(PyNone.java:28) 
        at org.python.core.Py.<clinit>(Py.java:62) 
        at org.python.core.Py.newStringMap(Py.java:850) 
        at org.python.util.PythonInterpreter.<init>(PythonInterpreter.java:99) 
        at org.python.util.PythonInterpreter.<init>(PythonInterpreter.java:93) 
        at org.python.util.PythonInterpreter.<init>(PythonInterpreter.java:70) 
        at com.zeechung.cartark.misc.ScriptEnv.<clinit>(ScriptEnv.java:27) 
        at com.zeechung.cartark.misc.ScriptEnv.python(ScriptEnv.java:31) 
        at com.zeechung.cartark.llm.QianfanLLM.lambda$static$0(QianfanLLM.java:105) 
        at com.zeechung.cartark.llm.QianfanLLM$$ExternalSyntheticLambda0.run(Unknown Source:0) 
        at java.lang.Thread.run(Thread.java:923) 
@jeff5
Copy link
Member

jeff5 commented May 3, 2024

I think Jython can't run on Android. We don't test on Android. It has been asked for a few times now. As I understand it, some API is absent that is necessary to load byte code generated at run time. If you can avoid that need in your application, it may be possible to compile all the modules and then translate the class files you get.

The amount missing is less in later versions of Android. I would like it to be possible eventually, and thought I knew roughly how.

However, I am surprised that ClassValue should be one of the missing pieces: that's really quite fundamental.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants