android 为什么会出现错误没有找到类“java.lang.ClassValue”?

d8tt03nd  于 2023-02-20  发布在  Android
关注(0)|答案(1)|浏览(298)

我在应用程序中使用jython-standalone-2.7.2.jar ...编译器是build.gradle中的Android Studio 2020 3.1 ... minSdk 26。

PythonInterpreter interp = new PythonInterpreter();

代码:

import org.python.util.PythonInterpreter;
import org.python.core.*;
public class SimpleEmbedded {
public static void main(String []args) throws PyException {
    [PythonInterpreter interp = new PythonInterpreter();][1]
  ///  System.out.println("Hello, world from Java");
  //  interp.execfile("hello.py");
  ///  interp.set("a", new PyInteger(42));
  //  interp.exec("print a");
  //  interp.exec("x = 2+2");
  //  PyObject x = interp.get("x");
  //  System.out.println("x: "+x);
    System.out.println("Goodbye ");
}
}

错误:

2021-09-29 21:19:12.368 3202-3202/com.serg.myjython E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.serg.myjython, PID: 3202
    **java.lang.NoClassDefFoundError: Failed resolution of: Ljava/lang/ClassValue**;
        at org.python.core.PyType.fromClass(PyType.java:2137)
...
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
     Caused by: **java.lang.ClassNotFoundException: Didn't find class "java.lang.ClassValue"** on path: DexPathList[[zip file "/data/app/~~VsbgLG28nD-Vw7dAU-vIyA==/com.serg.myjython-ODUx9HepPkKuKHI_uTVWdw==/base.apk"],nativeLibraryDirectories=[/data/app/~~VsbgLG28nD-Vw7dAU-vIyA==/com.serg.myjython-ODUx9HepPkKuKHI_uTVWdw==/lib/x86, /system/lib, /system_ext/lib]]
wpx232ag

wpx232ag1#

因为android jdk(内置在手机中)没有java.lang.ClassValue类,您应该从open JDKOracle JDK复制该类,并修复无法调用的API。

相关问题