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

ClassNotFoundException: Didn't find class "com.chaquo.python.PyException" #261

Closed
mhsmith opened this issue Apr 14, 2020 · 8 comments
Closed
Labels

Comments

@mhsmith
Copy link
Member

mhsmith commented Apr 14, 2020

Originally posted by @tongjinlv in #43 (comment)

I compiled into release but is run error
error message:
lang.ClassNotFoundException: Didn't find class "com.chaquo.python.PyException" on path: DexPathList[[zip file "/data/app/com.matatalab.matatacode-9_fj_Bw-RN1FBE6tu42f0A==/base.apk"],nativeLibraryDirectories=[/data/app/com.matatalab.matatacode-9_fj_Bw-RN1FBE6tu42f0A==/lib/arm64, /data/app/com.matatalab.matatacode-9_fj_Bw-RN1FBE6tu42f0A==/base.apk!/lib/arm64-v8a, /system/lib64, /product/lib64]]

@mhsmith
Copy link
Member Author

mhsmith commented Apr 14, 2020

Please post the full stack trace, and any relevant source code.

@tongjinlv
Copy link

The problem is solved due to the release mode compression, thank you very much

@mhsmith
Copy link
Member Author

mhsmith commented Aug 19, 2020

Originally posted by @zeynabimani in #358 (comment)

Hi. I have almost the same problem. I just want to start Python in my android application, but when I use this code I get an error.
The code is:

if (!Python.isStarted()) { Python.start(new AndroidPlatform(this)); }

When I use this code in any part of the program MainActivity or somewhere else I got the error and I don't know why?!

The error is:

2020-08-19 18:19:04.135 12263-12263/com.dji.sdk.sample E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.dji.sdk.sample, PID: 12263
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.dji.sdk.sample/com.dji.sdk.sample.internal.controller.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.chaquo.python.PyException" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/com.dji.sdk.sample-ImLlWv7TGO-MqNuoILbVIA==/base.apk", dex file "InMemoryDexFile[cookie=[0, 494810873152]]", dex file "InMemoryDexFile[cookie=[0, 494810874496]]"],nativeLibraryDirectories=[/data/app/com.dji.sdk.sample-ImLlWv7TGO-MqNuoILbVIA==/lib/arm64, /data/app/com.dji.sdk.sample-ImLlWv7TGO-MqNuoILbVIA==/base.apk!/lib/arm64-v8a, /system/lib64]]
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2977)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3114)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:113)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:71)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1859)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:201)
        at android.app.ActivityThread.main(ActivityThread.java:6831)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:927)
     Caused by: java.lang.ClassNotFoundException: Didn't find class "com.chaquo.python.PyException" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/com.dji.sdk.sample-ImLlWv7TGO-MqNuoILbVIA==/base.apk", dex file "InMemoryDexFile[cookie=[0, 494810873152]]", dex file "InMemoryDexFile[cookie=[0, 494810874496]]"],nativeLibraryDirectories=[/data/app/com.dji.sdk.sample-ImLlWv7TGO-MqNuoILbVIA==/lib/arm64, /data/app/com.dji.sdk.sample-ImLlWv7TGO-MqNuoILbVIA==/base.apk!/lib/arm64-v8a, /system/lib64]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:171)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
        at com.chaquo.python.Python.startNative(Native Method)
        at com.chaquo.python.Python.a(:50)
        at com.dji.sdk.sample.internal.controller.MainActivity.onCreate(:113)
        at android.app.Activity.performCreate(Activity.java:7224)
        at android.app.Activity.performCreate(Activity.java:7213)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2957)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3114) 
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78) 
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:113) 
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:71) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1859) 
        at android.os.Handler.dispatchMessage(Handler.java:106) 
        at android.os.Looper.loop(Looper.java:201) 
        at android.app.ActivityThread.main(ActivityThread.java:6831) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:927) 

I read the documentation, and I know one way for starting python is to change the application name in androidManifest.xml file, but I can't do this because I use a Sample Application, and I can't change the application name in the manifest file.

Can you please help me find the problem?

@mhsmith mhsmith reopened this Aug 19, 2020
@mhsmith
Copy link
Member Author

mhsmith commented Aug 19, 2020

The problem is solved due to the release mode compression, thank you very much

@tongjinlv: can you explain what you mean by this? For example, was it affected by the build variant? What exactly did you do to solve it?

@mhsmith
Copy link
Member Author

mhsmith commented Aug 19, 2020

@zeynabimani: Changing the application name in the AndroidManifest.xml shouldn't be necessary, because they only thing PyApplication does is make that same Python.start call.

Which devices or emulators have you tried running the app on, and did they all show the same problem?

@mhsmith
Copy link
Member Author

mhsmith commented Aug 19, 2020

OK, I think I've found the cause. Try editing your build.gradle file to change every appearance of minifyEnabled true to minifyEnabled false.

This will be fixed in the next version of Chaquopy.

@mhsmith mhsmith added the bug label Aug 19, 2020
@zeynabimani
Copy link

Thank you very much @mhsmith.
My problem solved by changing minifyEnabled true to minifyEnabled false.

@mhsmith
Copy link
Member Author

mhsmith commented Nov 6, 2020

This issue is fixed in Chaquopy 9.0.0. To upgrade, edit your app's top-level build.gradle file and change the version number of com.chaquo.python:gradle.

@mhsmith mhsmith closed this as completed Nov 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants