Having the following problem, when I build my project and run it on my connected Samsung Galaxy S8 phone, it immediately crashes. Using adb logcat I can see the following being logged:
AndroidRuntime: java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.Nonline.Fungi/com.unity3d.player.UnityPlayerNativeActivity}: java.lang.ClassNotFoundException: Didn’t find class “com.unity3d.player.UnityPlayerNativeActivity” on path: DexPathList[[zip file “/data/app/com.Nonline.Fungi-exNRLbXEt63sivniy501kw==/base.apk”],nativeLibraryDirectories=[/data/app/com.Nonline.Fungi-exNRLbXEt63sivniy501kw==/lib/arm, /data/app/com.Nonline.Fungi-exNRLbXEt63sivniy501kw==/base.apk!/lib/armeabi-v7a, /system/lib, /system/vendor/lib]]
Using Unity 2018.3.0f2 and I’m not using any external plugins that I know of. Suggestions?
Did you upgrade your project from an old Unity version? Do you have a custom main manifest? It seems that an old main activity name (“com.unity3d.player.UnityPlayerNativeActivity”) is specified in your manifest. Changing that to “com.unity3d.player.UnityPlayerActivity” should fix your issue.
Solved!
Turns out there was an Android manifest file for a plugin I didn’t use anymore with “com.unity3d.player.UnityPlayerNativeActivity” in it. Thanks!
Had same issue since I updated unity through the Hub yesterday. This helped me as well! Manually change the manifest file did it, but it also encouraged me to check for updates on my custom packages, “CloudOnce” to be specific, there was an update from 6 days ago which included a fix in the manifest among other updates.
Can recommend other to update packages when encountering this issue
Having the main name as “com.unity3d.player.UnityPlayerActivity” in manifest. But game is crashing at start and when debugged it shows error as java.lang.ClassNotFoundException: Didn’t find class : “com.example.companyname.UnityPlayerActivity”
I am using 2019.2 and have upgraded from 2017. What should I do?
Does removing the plugin make a difference? Also you should have a main manifest if you’re building for Android. I think a recent plugin change is what you’re looking for.
Also what is the crash message, were you able to log it?
I have tried implementing the AndroidManifest from Temp/Staging into my Plugins/Android.
I also tried copying default AndroidManifest from /Applications/Unity/Hub/Editor/2019.2.17f1/PlaybackEngines/AndroidPlayer/Apk/AndroidManifest.xml
If I remove the plugin (via packagamanager, like it’s implemented), the game will compile and work as expected.
Finally. Log crash is bellow.
And I can confirm the classes ‘com.unity…’, ‘com.mygamename…’ are indeed missing from the APK.
--------- beginning of crash
01-29 12:56:01.175 12800 12800 E AndroidRuntime: FATAL EXCEPTION: main
01-29 12:56:01.175 12800 12800 E AndroidRuntime: Process: com.rebubbled.bubblestruggle, PID: 12800
01-29 12:56:01.175 12800 12800 E AndroidRuntime: java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.rebubbled.bubblestruggle/com.unity3d.player.UnityPlayerActivity}: java.lang.ClassNotFoundException: Didn't find class "com.unity3d.player.UnityPlayerActivity" on path: DexPathList[[zip file "/data/app/com.rebubbled.bubblestruggle-ldDl4Hz04tlSMTfsSDSRpg==/base.apk"],nativeLibraryDirectories=[/data/app/com.rebubbled.bubblestruggle-ldDl4Hz04tlSMTfsSDSRpg==/lib/arm64, /data/app/com.rebubbled.bubblestruggle-ldDl4Hz04tlSMTfsSDSRpg==/base.apk!/lib/arm64-v8a, /system/lib64]]
01-29 12:56:01.175 12800 12800 E AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2863)
01-29 12:56:01.175 12800 12800 E AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3099)
01-29 12:56:01.175 12800 12800 E AndroidRuntime: at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
01-29 12:56:01.175 12800 12800 E AndroidRuntime: at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
01-29 12:56:01.175 12800 12800 E AndroidRuntime: at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
01-29 12:56:01.175 12800 12800 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1826)
01-29 12:56:01.175 12800 12800 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:106)
01-29 12:56:01.175 12800 12800 E AndroidRuntime: at android.os.Looper.loop(Looper.java:193)
01-29 12:56:01.175 12800 12800 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:6862)
01-29 12:56:01.175 12800 12800 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
01-29 12:56:01.175 12800 12800 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:504)
01-29 12:56:01.175 12800 12800 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:870)
01-29 12:56:01.175 12800 12800 E AndroidRuntime: Caused by: java.lang.ClassNotFoundException: Didn't find class "com.unity3d.player.UnityPlayerActivity" on path: DexPathList[[zip file "/data/app/com.rebubbled.bubblestruggle-ldDl4Hz04tlSMTfsSDSRpg==/base.apk"],nativeLibraryDirectories=[/data/app/com.rebubbled.bubblestruggle-ldDl4Hz04tlSMTfsSDSRpg==/lib/arm64, /data/app/com.rebubbled.bubblestruggle-ldDl4Hz04tlSMTfsSDSRpg==/base.apk!/lib/arm64-v8a, /system/lib64]]
Made some progress. The problem seems to be that I am loading the plugin from the packagemanager. AndroidManifest is handled differently than simply implementing the plugin inside my Plugins/Android/ folder.
I believe the specificity of the AndroidManifest from the plugin overwrites the default Unity manifest no matter if I have a manifest inside my project’s Plugins/Androind/ or not. Manifest merger is unable to merge nodes like ‘application’… so they get overwritten. Anyways, got it to work so I’ll figure it out from here. Thanks for your help!!
This was a huge revelation for me too! Anytime a new android specific plugin is added, the manifest is overwritten and the old manifest’s application nodes get completely re written. Before adding any new plugins just make sure you keep a copy of the main manifest and add whatever was removed during the overwriting process.
Can’t believe this isn’t handled by Unity.
Anyway, glad you got it working. Cheers!
How could Unity handle this in your opinion?
Any plugin that fully overwrites main manifest is written incorrectly. Unity officially supports AAR plugins and Android Libraries (https://docs.unity3d.com/Manual/AndroidAARPlugins.html). They both contain manifest which is merged into the main manifest when building the application. Properly written plugins should not replace main manifest in Plugins/Android directory.