Ionic/Cordova app does not find MainActivity - android

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?

I solved it.
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.

Related

Android MapBox Java SDK error when displaying map

I'm trying to use the sdk in a java android project.
I use this sdk :
implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:6.3.0'
When i launch the screen with the Mapview, i got the "getDataNetworkTypeForSubscriber" error
When searching a solution to this error multiple answer tell to import this dependency
implementation 'com.mapbox.mapboxsdk:mapbox-android-telemetry:6.3.0'
But when i launch the screen with this dependecy i got this error :
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/mapbox/android/telemetry/MapEventFactory;
....
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.mapbox.android.telemetry.MapEventFactory" on path: DexPathList[[zip file "/data/app/~~rUziWglMhPfBsvW8AaITbQ==/com.trema.encheres.dev-aI_CEkUkLFmlvawtp7adLQ==/base.apk"],nativeLibraryDirectories=[/data/app/~~rUziWglMhPfBsvW8AaITbQ==/com.trema.encheres.dev-aI_CEkUkLFmlvawtp7adLQ==/lib/arm64, /data/app/~~rUziWglMhPfBsvW8AaITbQ==/com.trema.encheres.dev-aI_CEkUkLFmlvawtp7adLQ==/base.apk!/lib/arm64-v8a, /system/lib64, /system_ext/lib64]]
What am I doing wrong ? Is there something i forgot ? A dependency ?
I try to add this dependency
implementation 'com.mapbox.mapboxsdk:mapbox-sdk-core:6.3.0'
but i got the error message when building :
Could not find com.mapbox.mapboxsdk:mapbox-sdk-core:6.3.0.
Thanks

Class not found at run time though it's in apk file

I'm trying to run a program on the phone from android studio. It tries to send an email using javax.mail. When running under the debugger, see these errors in the debug console.
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/sun/mail/util/MailLogger;
at javax.mail.Session.initLogger(Session.java:261)
at javax.mail.Session.<init>(Session.java:245)
at javax.mail.Session.getDefaultInstance(Session.java:356)
at com.example.sendemail.GMailSender.<init>(GMailSender.java:53)
...
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.sun.mail.util.MailLogger" on path: DexPathList[...]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at javax.mail.Session.initLogger(Session.java:261) 
...
The class com/sun/mail/util/MailLogger is present in the apk. Found this from 'Analyze APK' (image below). It's in classes.dex. Why isn't it found at run time?
Android Studio version 3.4.1
Android version on phone is 7.0

ClassNotFoundException thrown after Data/Cache cleaning - second run OK

The application I am working on shows a strange symptom - if one cleans data and cache of the application, the application will crash on the first next run with exception, but on the second run it will run without a problem. Does anybody have any idea what could be going on and how to fix it.
What I already did:
deleted all the build dirs and rebuild
disabled instant run
check that the class is in the apk
tired it on multiple phones - all behave the same
Sadly nothing helped...
I am using the latest Android Studio 3.2.1. Compile and target SDK is 28, minimal 21. The app is written in Kotlin. Support lib is 28.0.0 and build tools 28.0.3.
The exception thrown on the first run (the name of the application was changed to protect the innocent):
2018-11-26 18:18:38.780 17135-17135/com.myapp.app E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.myapp.app, PID: 17135
java.lang.RuntimeException: Unable to instantiate service service.ServerNotificationService: java.lang.ClassNotFoundException: Didn't find class "service.ServerNotificationService" on path: DexPathList[[zip file "/data/app/com.myapp.app-YIEEjJIdfXs58PSDfpg4Ew==/base.apk"],nativeLibraryDirectories=[/data/app/com.myapp.app-YIEEjJIdfXs58PSDfpg4Ew==/lib/arm64, /data/app/com.myapp.app-YIEEjJIdfXs58PSDfpg4Ew==/base.apk!/lib/arm64-v8a, /system/lib64, /system/vendor/lib64]]
at android.app.ActivityThread.handleCreateService(ActivityThread.java:3459)
at android.app.ActivityThread.-wrap4(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1702)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6710)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:770)
Caused by: java.lang.ClassNotFoundException: Didn't find class "service.ServerNotificationService" on path: DexPathList[[zip file "/data/app/com.myapp.app-YIEEjJIdfXs58PSDfpg4Ew==/base.apk"],nativeLibraryDirectories=[/data/app/com.myapp.app-YIEEjJIdfXs58PSDfpg4Ew==/lib/arm64, /data/app/com.myapp.app-YIEEjJIdfXs58PSDfpg4Ew==/base.apk!/lib/arm64-v8a, /system/lib64, /system/vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:3456)
at android.app.ActivityThread.-wrap4(Unknown Source:0) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1702) 
at android.os.Handler.dispatchMessage(Handler.java:105) 
at android.os.Looper.loop(Looper.java:164) 
at android.app.ActivityThread.main(ActivityThread.java:6710) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:770) 
So I managed to fix it. It was related to how Android tools merge AndroidManifest.xml files.
Let me explain (for posterity):
The application I am building is composed from a core - which is an android library and the actual application. The class service.ServerNotificationService is part of the library and was declared in AndroidManifest.xml of the said library as:
<service android:name="service.ServerNotificationService" />
Which is correct and the app will run - just not with the clean cache (I still do not understand this part, but I presume it has something to do with the black magic which is Android ART). To fix the problem I changed the line to:
<service android:name="com.myapp.app.core.service.ServerNotificationService" />
Which is the full name for the class. The lesson learned here is always use full class name in the libraries...

GCM push noti in Unity3d causes gms.iid.InstanceID classnotfound

I have made an Android plugin to use GCM in my Unity app. When I try to start the RegistrationIntentService (readymade example class from Android Developer Manual site), it causes a crash with the exception
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.iid.InstanceID" on path: DexPathList[[zip file "/data/app/com.ex.test-1/base.apk"],nativeLibraryDirectories=[/data/app/com.ex.test-1/lib/arm, /vendor/lib, /system/lib]]
I have imported the play-services-9.2.0.unitypackage, without any success. Any help?
For anyone who might want to look for this question answered, I found the solution. The InstanceID.class is not included in the play-services-9.2.0.unitypackage, so include the play-services-iid-9.0.2.aar in the Android -> Plugins folder.

android ClassNotFoundException after trying to change minimum sdk

I am really getting desperate.
I have a working app - theoretically.
Tried to change the sdk version from 8 to 13.
Now when I start the app I get a Fatal exception, or rather a ClassNotFoundException for the very first activity started:
10-15 16:56:22.370: E/AndroidRuntime(862): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.pris/com.example.pris.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.example.pris.MainActivity" on path: DexPathList[[zip file "/data/app/com.example.pris-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.pris-1, /system/lib]]
Apparently there seems to be some mixup with paths, but I have not the slightes idea where, or how to fix this.
Please help!
clean rebuild and restart project.. btw do you have any additional libraries??
if so get rid of them
lol..

Categories

Resources