cordova-android
cordova-android copied to clipboard
java.lang.RuntimeException: Unable to instantiate activity
Bug Report
Problem
Application crash when launch from Play Store (Appbundle), but no probleme with APK
What is expected to happen?
Application launch
What does actually happen?
Crash, no window or anything launched. just received an ANR
Information
06-27 12:19:42.079 18662 18662 E AndroidRuntime: FATAL EXCEPTION: main
06-27 12:19:42.079 18662 18662 E AndroidRuntime: Process: io.aninet.companion, PID: 18662
06-27 12:19:42.079 18662 18662 E AndroidRuntime: java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{io.aninet.companion/io.aninet.companion.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "io.aninet.companion.MainActivity" on path: DexPathList[[zip file "/data/app/~~sWz4qul_KjndIS0h84bN3A==/io.aninet.companion-tdXX0h9zkUn8RR35_i3aKw==/base.apk", zip file "/data/app/~~sWz4qul_KjndIS0h84bN3A==/io.aninet.companion-tdXX0h9zkUn8RR35_i3aKw==/split_config.fr.apk", zip file "/data/app/~~sWz4qul_KjndIS0h84bN3A==/io.aninet.companion-tdXX0h9zkUn8RR35_i3aKw==/split_config.xxhdpi.apk"],nativeLibraryDirectories=[/data/app/~~sWz4qul_KjndIS0h84bN3A==/io.aninet.companion-tdXX0h9zkUn8RR35_i3aKw==/lib/arm64, /system/lib64, /system_ext/lib64]]
06-27 12:19:42.079 18662 18662 E AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3613)
06-27 12:19:42.079 18662 18662 E AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3844)
06-27 12:19:42.079 18662 18662 E AndroidRuntime: at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:101)
06-27 12:19:42.079 18662 18662 E AndroidRuntime: at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
06-27 12:19:42.079 18662 18662 E AndroidRuntime: at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
06-27 12:19:42.079 18662 18662 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2315)
06-27 12:19:42.079 18662 18662 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:106)
06-27 12:19:42.079 18662 18662 E AndroidRuntime: at android.os.Looper.loopOnce(Looper.java:201)
06-27 12:19:42.079 18662 18662 E AndroidRuntime: at android.os.Looper.loop(Looper.java:288)
06-27 12:19:42.079 18662 18662 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:7929)
06-27 12:19:42.079 18662 18662 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
06-27 12:19:42.079 18662 18662 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
06-27 12:19:42.079 18662 18662 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
06-27 12:19:42.079 18662 18662 E AndroidRuntime: Caused by: java.lang.ClassNotFoundException: Didn't find class "io.aninet.companion.MainActivity" on path: DexPathList[[zip file "/data/app/~~sWz4qul_KjndIS0h84bN3A==/io.aninet.companion-tdXX0h9zkUn8RR35_i3aKw==/base.apk", zip file "/data/app/~~sWz4qul_KjndIS0h84bN3A==/io.aninet.companion-tdXX0h9zkUn8RR35_i3aKw==/split_config.fr.apk", zip file "/data/app/~~sWz4qul_KjndIS0h84bN3A==/io.aninet.companion-tdXX0h9zkUn8RR35_i3aKw==/split_config.xxhdpi.apk"],nativeLibraryDirectories=[/data/app/~~sWz4qul_KjndIS0h84bN3A==/io.aninet.companion-tdXX0h9zkUn8RR35_i3aKw==/lib/arm64, /system/lib64, /system_ext/lib64]]
06-27 12:19:42.079 18662 18662 E AndroidRuntime: at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:259)
06-27 12:19:42.079 18662 18662 E AndroidRuntime: at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
06-27 12:19:42.079 18662 18662 E AndroidRuntime: at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
06-27 12:19:42.079 18662 18662 E AndroidRuntime: at android.app.AppComponentFactory.instantiateActivity(AppComponentFactory.java:95)
06-27 12:19:42.079 18662 18662 E AndroidRuntime: at androidx.core.app.CoreComponentFactory.instantiateActivity(CoreComponentFactory.java:45)
06-27 12:19:42.079 18662 18662 E AndroidRuntime: at android.app.Instrumentation.newActivity(Instrumentation.java:1328)
06-27 12:19:42.079 18662 18662 E AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3600)
06-27 12:19:42.079 18662 18662 E AndroidRuntime: ... 12 more
06-27 12:19:42.079 18662 18662 E AndroidRuntime: Suppressed: java.io.IOException: Failed to open dex files from /data/app/~~sWz4qul_KjndIS0h84bN3A==/io.aninet.companion-tdXX0h9zkUn8RR35_i3aKw==/split_config.fr.apk because: Entry not found
06-27 12:19:42.079 18662 18662 E AndroidRuntime: at dalvik.system.DexFile.openDexFileNative(Native Method)
06-27 12:19:42.079 18662 18662 E AndroidRuntime: at dalvik.system.DexFile.openDexFile(DexFile.java:371)
06-27 12:19:42.079 18662 18662 E AndroidRuntime: at dalvik.system.DexFile.
Command or Code
cordova run
Environment, Platform, Device
Windows 10 (21H2) Phone side: Android 12 or 13 (same results) And Google Play testing devices is showing same problem.
Version information
Cordova 11.0 Installed platforms: android 10.1.2
Checklist
- [X] I searched for existing GitHub issues
- [X] I updated all Cordova tooling to most recent version
- [X] I included all the necessary information above
Cordova run work, but when using cordova build with build.json provided on the doc, it's not working. Cordova build a correct bundle but when it's installed by Play store, the error occur.
My build.json: { "android": { "debug": { "keystore": "./danielvalat-teslina.keystore", "storePassword": "", "alias": "fr.danielvalat", "password" : "", "keystoreType": "", "packageType": "apk" }, "release": { "keystore": "./danielvalat-teslina.keystore", "storePassword": "", "alias": "fr.danielvalat", "password" : "", "keystoreType": "", "packageType": "bundle" } } }
Fixed by editing \platforms\android\app\src\main\AndroidManifest.xml
Have you changed the app id since you used cordova platform add android? If so this is a path that would cause this runtime error.
It's being fixed by https://github.com/apache/cordova-android/pull/1154 but this will only be included in our next 11.x release.
The current workaround is to re-add the platform via
cordova platform remove android
cordova platform add android
Hello, The problem is not here. When i'm using APK (build with a simple cordova build) it's working. But when i build an appbundle it's not working because the AndroidManifest.xml is set to "MainActivity" and not ".MainActivity".
I don't known if i'm clear, i'm french sorry.
I don't known if i'm clear, i'm french sorry.
No worries, you're good.
Ok thanks for confirming that this isn't related to the aforementioned issue. I think the next best thing to help move this along is if you can provide a sample reproduction repository that reproduces this issue.
- Build a new cordova app and use the same bundle id as your real app
- For this particular issue, I don't think you need to include any actual app sources, the hello world app should be sufficient.
- To test if the sample repository reproduces your issue, you can use your build.json / keystore, but do NOT include them inside the sample repository
To avoid testing the bundle by uploading it to the play store, you can use Google's Bundletool. With the bundle tool, you can generate an APK Set, which can then be installed onto your device. This is how I will also test the reproduction sample.
Hello, sorry for the delay. I'm doing that when i have 5 minutes ;) Thank you for your reply. This problem occur with a sample project, nothing to do with a moidified namespace.
And thanks for bundletool
Closing as stale.