# Unity app crashes when using unmodified custom Android manifest (didn't find class “UnityPlayerActivity”)

Note: I find/replaced my actual company name with 'companyname' below for anonymity, it's not the actual package name I am using.

I have Unity 2018.4.11f1 LTS and the platform I'm having issues with is a Google Glass Enterprise Edition 2 running Android 8.1.0.

I'm new to both Unity and Android programming. My goal is to add some extra category specifiers to AppManifest.xml. As I understand it, to modify the manifest, I need to take Unity's generated manifest, copy it to my project to use as a starting point, then modify it.

However, when I perform the following steps:

1. Export the project from Unity.
2. Take the generated manifest (src/main/AppManifest.xml) and copy it into my project (Assets/Plugins/Android/AppManifest.xml).
3. Build and run the project without modifying the manifest file just as a test.

... the app crashes immediately, with the following showing up in logcat:

10-28 18:09:31.612: D/AndroidRuntime(2560): --------- beginning of crash
10-28 18:09:31.613: E/AndroidRuntime(2560): FATAL EXCEPTION: main
10-28 18:09:31.613: E/AndroidRuntime(2560): Process: com.companyname.glass.screen, PID: 2560
10-28 18:09:31.613: E/AndroidRuntime(2560): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.companyname.glass.screen/com.companyname.glass.screen.UnityPlayerActivity}: java.lang.ClassNotFoundException: Didn't find class "com.companyname.glass.screen.UnityPlayerActivity" on path: DexPathList[[zip file "/data/app/com.companyname.glass.screen-hmosf9MV2zscOjvPt7Az6A==/base.apk"],nativeLibraryDirectories=[/data/app/com.companyname.glass.screen-hmosf9MV2zscOjvPt7Az6A==/lib/arm, /data/app/com.companyname.glass.screen-hmosf9MV2zscOjvPt7Az6A==/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib]]
10-28 18:09:31.613: E/AndroidRuntime(2560):     at android.app.ActivityThread.-wrap11(Unknown Source:0)
10-28 18:09:31.613: E/AndroidRuntime(2560):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1592) 10-28 18:09:31.613: E/AndroidRuntime(2560): at android.os.Handler.dispatchMessage(Handler.java:106) 10-28 18:09:31.613: E/AndroidRuntime(2560): at android.os.Looper.loop(Looper.java:164) 10-28 18:09:31.613: E/AndroidRuntime(2560): at android.app.ActivityThread.main(ActivityThread.java:6518) 10-28 18:09:31.613: E/AndroidRuntime(2560): at java.lang.reflect.Method.invoke(Native Method) 10-28 18:09:31.613: E/AndroidRuntime(2560): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
10-28 18:09:31.613: E/AndroidRuntime(2560):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
10-28 18:09:31.613: E/AndroidRuntime(2560): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.companyname.glass.screen.UnityPlayerActivity" on path: DexPathList[[zip file "/data/app/com.companyname.glass.screen-hmosf9MV2zscOjvPt7Az6A==/base.apk"],nativeLibraryDirectories=[/data/app/com.companyname.glass.screen-hmosf9MV2zscOjvPt7Az6A==/lib/arm, /data/app/com.companyname.glass.screen-hmosf9MV2zscOjvPt7Az6A==/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib]]
10-28 18:09:31.613: E/AndroidRuntime(2560):     at android.app.Instrumentation.newActivity(Instrumentation.java:1175)
10-28 18:09:31.613: E/AndroidRuntime(2560):     ... 9 more
10-28 18:09:31.619: W/ActivityManager(1203):   Force finishing activity com.companyname.glass.screen/.UnityPlayerActivity


Where the primary error is:

java.lang.ClassNotFoundException: Didn't find class "com.companyname.glass.screen.UnityPlayerActivity"

Normally the app runs fine. I don't understand what is happening, because this is the exact unmodified manifest that Unity generates, no changes. But when I put it in my project, the app crashes.

Here's the manifest that Unity generates, which is the one I'm using:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.companyname.glass.screen" xmlns:tools="http://schemas.android.com/tools" android:installLocation="preferExternal">
<supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" android:anyDensity="true" />
<application android:theme="@style/UnityThemeSelector" android:icon="@mipmap/app_icon" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data android:name="unityplayer.UnityActivity" android:value="true" />
</activity>
<meta-data android:name="unity.build-id" android:value="5bffbf6f-0a59-4843-8b47-d3b5ac51b8dd" />
<meta-data android:name="unity.splash-mode" android:value="0" />
<meta-data android:name="unity.splash-enable" android:value="True" />
</application>
<uses-feature android:glEsVersion="0x00020000" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-feature android:name="android.hardware.touchscreen" android:required="false" />
<uses-feature android:name="android.hardware.touchscreen.multitouch" android:required="false" />
<uses-feature android:name="android.hardware.touchscreen.multitouch.distinct" android:required="false" />
</manifest>


My question is: Why is this happening and how do I make it not happen so that I can add the <category/> element I need to add?

Update: So I just took a look inside the generated APK file, and I see that it does include a class named com.unity3d.player.UnityPlayerActivity. I am not sure why it's looking for UnityPlayerActivity in my app's package instead of com.unity3d.player.

Ok, I got it working, I manually changed android:name in the application element from com.companyname.glass.screen.UnityPlayerActivity to com.unity3d.player.UnityPlayerActivity. But I'm not going to attempt to post a self-answer because I have no idea why I had to do that or if that was the "proper" solution. Will accept any reasonable explanation of this. (I arrived at this conclusion by comparing the manifests from the APKs both with and without my custom manifest; I do not understand why Unity filled in an incorrect application class name with "Export" vs "Build and Run").

• I do not think you can have a id of 'com.companyname.glass.screen' – Justin Markwell Oct 28 '19 at 22:43
• @JustinMarkwell If you mean because of companyname I just find/replaced my actual company name before posting for anonymity. – Jason C Oct 28 '19 at 22:43
• I meant that the 'glass.screen' should be 'com.companyname.glassscreen' – Justin Markwell Oct 28 '19 at 22:46
• So I just took a look inside the generated APK file, and I see that it does include a class named com.unity3d.player.UnityPlayerActivity. I am not sure why it's looking for UnityPlayerActivity in my app's package instead of com.unity3d.player? – Jason C Oct 28 '19 at 22:57
• Ok, I got it working, I changed android:name in the application element from com.companyname.glass.screen.UnityPlayerActivity to com.unity3d.player.UnityPlayerActivity. But I'm not going to attempt to post a self-answer because I have no idea why I had to do that or if that was the "proper" solution. Will accept any reasonable explanation of this. (I arrived at this conclusion by comparing the manifests from the APKs both with and without my custom manifest; I do not understand why Unity filled in an incorrect application class name with "Export" vs "Build and Run"). – Jason C Oct 28 '19 at 23:09

I do not think you can have a id of 'com.companyname.glass.screen'

try replacing that to 'com.companyname.glassscreen' and see if that compiles.

make sure you changed that part in the manifest

package="com.companyname.glassscreen" and matched to the same name in File>BuildSettings>PlayerSettings>

then in inspector it will be package name there by Identification

the main thing is that they all match one way or another.

• Thanks; I just changed the package name from com.companyname.glass.screen to com.companyname.ggee (I got rid of both "glass" and "screen" in case it was confusing some parser somewhere) then went through the same process. Same results: App runs fine until I copy the generated manifest into my project, then it crashes with Didn't find class "com.companyname.ggee.UnityPlayerActivity". – Jason C Oct 28 '19 at 22:52
• Re: Your edit: I deleted my custom manifest, changed it in Player Settings, re-exported the manifest, verified that it contained the new package name, then copied it back to my project and tried again. So yeah I can confirm I used a custom manifest with a matching package name after changing it. – Jason C Oct 28 '19 at 23:07