App crashes on start

My app (Ionic 5 + Cordova 9.1.0) crashes when I try to start it on an Android 11 phone. When I look into the logs with logcat I see that the main activity is not found:

10-21 16:31:29.281 5300 5300 E AndroidRuntime: java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{de.meingolfclub.myapp/de.meingolfclub.myapp.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "de.meingolfclub.myapp.MainActivity" on path: DexPathList[[zip file "/data/app/~~7FMRVcshmIuFxkzCRS8B2g==/de.meingolfclub.myapp-kbOatrQJj_K4ZJHsuXESTg==/base.apk"],nativeLibraryDirectories=[/data/app/~~7FMRVcshmIuFxkzCRS8B2g==/de.meingolfclub.myapp-kbOatrQJj_K4ZJHsuXESTg==/lib/arm64, /data/app/~~7FMRVcshmIuFxkzCRS8B2g==/de.meingolfclub.myapp-kbOatrQJj_K4ZJHsuXESTg==/base.apk!/lib/arm64-v8a, /system/lib64, /system_ext/lib64]]

I googled a bit and it seems to be related to multiDex functionality of Android, but I have no idea how to fix this in an Ionic/Cordova project.

What can I do to solve this problem?

What does your android/app/src/main/java/de/meingolfclub/myapp/ file look like? The path should have been updated from android/app/src/main/java/io/ionic/starter since the app name has been updated.

Does it have the following at the top:

package de.meingolfclub.myapp
1 Like

Man, you saved my weekend! Thanks a lot !!!

There was a wrong package name in MainActivity. After removing the Android platform and adding it again the package name was correct. And after a build the starts again.

1 Like