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

java.lang.RuntimeException: Unable to instantiate activity #1445

Closed
3 tasks done
DanielVALAT opened this issue Jun 27, 2022 · 9 comments
Closed
3 tasks done

java.lang.RuntimeException: Unable to instantiate activity #1445

DanielVALAT opened this issue Jun 27, 2022 · 9 comments
Labels
info-needed / awaiting response Further information is requested

Comments

@DanielVALAT
Copy link

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.(DexFile.java:113)
06-27 12:19:42.079 18662 18662 E AndroidRuntime: at dalvik.system.DexFile.(DexFile.java:86)
06-27 12:19:42.079 18662 18662 E AndroidRuntime: at dalvik.system.DexPathList.loadDexFile(DexPathList.java:438)
06-27 12:19:42.079 18662 18662 E AndroidRuntime: at dalvik.system.DexPathList.makeDexElements(DexPathList.java:397)
06-27 12:19:42.079 18662 18662 E AndroidRuntime: at dalvik.system.DexPathList.(DexPathList.java:166)
06-27 12:19:42.079 18662 18662 E AndroidRuntime: at dalvik.system.BaseDexClassLoader.(BaseDexClassLoader.java:160)
06-27 12:19:42.079 18662 18662 E AndroidRuntime: at dalvik.system.BaseDexClassLoader.(BaseDexClassLoader.java:130)
06-27 12:19:42.079 18662 18662 E AndroidRuntime: at dalvik.system.PathClassLoader.(PathClassLoader.java:146)
06-27 12:19:42.079 18662 18662 E AndroidRuntime: at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:93)
06-27 12:19:42.079 18662 18662 E AndroidRuntime: at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:134)
06-27 12:19:42.079 18662 18662 E AndroidRuntime: at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:126)
06-27 12:19:42.079 18662 18662 E AndroidRuntime: at android.app.ApplicationLoaders.getClassLoaderWithSharedLibraries(ApplicationLoaders.java:61)
06-27 12:19:42.079 18662 18662 E AndroidRuntime: at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:1034)
06-27 12:19:42.079 18662 18662 E AndroidRuntime: at android.app.LoadedApk.getClassLoader(LoadedApk.java:1126)
06-27 12:19:42.079 18662 18662 E AndroidRuntime: at android.app.LoadedApk.getResources(LoadedApk.java:1374)
06-27 12:19:42.079 18662 18662 E AndroidRuntime: at android.app.ContextImpl.createAppContext(ContextImpl.java:3090)
06-27 12:19:42.079 18662 18662 E AndroidRuntime: at android.app.ContextImpl.createAppContext(ContextImpl.java:3082)
06-27 12:19:42.079 18662 18662 E AndroidRuntime: at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6707)
06-27 12:19:42.079 18662 18662 E AndroidRuntime: at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0)
06-27 12:19:42.079 18662 18662 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2141)
06-27 12:19:42.079 18662 18662 E AndroidRuntime: ... 7 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.xxhdpi.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.(DexFile.java:113)
06-27 12:19:42.079 18662 18662 E AndroidRuntime: at dalvik.system.DexFile.(DexFile.java:86)
06-27 12:19:42.079 18662 18662 E AndroidRuntime: at dalvik.system.DexPathList.loadDexFile(DexPathList.java:438)
06-27 12:19:42.079 18662 18662 E AndroidRuntime: at dalvik.system.DexPathList.makeDexElements(DexPathList.java:397)
06-27 12:19:42.079 18662 18662 E AndroidRuntime: at dalvik.system.DexPathList.(DexPathList.java:166)
06-27 12:19:42.079 18662 18662 E AndroidRuntime: at dalvik.system.BaseDexClassLoader.(BaseDexClassLoader.java:160)
06-27 12:19:42.079 18662 18662 E AndroidRuntime: at dalvik.system.BaseDexClassLoader.(BaseDexClassLoader.java:130)
06-27 12:19:42.079 18662 18662 E AndroidRuntime: at dalvik.system.PathClassLoader.(PathClassLoader.java:146)
06-27 12:19:42.079 18662 18662 E AndroidRuntime: at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:93)
06-27 12:19:42.079 18662 18662 E AndroidRuntime: at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:134)
06-27 12:19:42.079 18662 18662 E AndroidRuntime: at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:126)
06-27 12:19:42.079 18662 18662 E AndroidRuntime: at android.app.ApplicationLoaders.getClassLoaderWithSharedLibraries(ApplicationLoaders.java:61)
06-27 12:19:42.079 18662 18662 E AndroidRuntime: at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:1034)
06-27 12:19:42.079 18662 18662 E AndroidRuntime: at android.app.LoadedApk.getClassLoader(LoadedApk.java:1126)
06-27 12:19:42.079 18662 18662 E AndroidRuntime: at android.app.LoadedApk.getResources(LoadedApk.java:1374)
06-27 12:19:42.079 18662 18662 E AndroidRuntime: at android.app.ContextImpl.createAppContext(ContextImpl.java:3090)
06-27 12:19:42.079 18662 18662 E AndroidRuntime: at android.app.ContextImpl.createAppContext(ContextImpl.java:3082)
06-27 12:19:42.079 18662 18662 E AndroidRuntime: at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6707)
06-27 12:19:42.079 18662 18662 E AndroidRuntime: at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0)
06-27 12:19:42.079 18662 18662 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2141)
06-27 12:19:42.079 18662 18662 E AndroidRuntime: ... 7 more
0

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

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above
@DanielVALAT
Copy link
Author

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.

@DanielVALAT
Copy link
Author

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"
}
}
}

@DanielVALAT
Copy link
Author

Fixed by editing \platforms\android\app\src\main\AndroidManifest.xml adding a dot before MainActivity

@breautek
Copy link
Contributor

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 #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

@DanielVALAT
Copy link
Author

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.

@breautek
Copy link
Contributor

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.

@DanielVALAT
Copy link
Author

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.

@DanielVALAT
Copy link
Author

And thanks for bundletool

@breautek breautek added the info-needed / awaiting response Further information is requested label Jul 22, 2022
@breautek
Copy link
Contributor

Closing as stale.

@breautek breautek closed this as not planned Won't fix, can't repro, duplicate, stale Apr 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
info-needed / awaiting response Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants