Game Development Asked on January 7, 2022
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:
… 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.performLaunchActivity(ActivityThread.java:2682)
10-28 18:09:31.613: E/AndroidRuntime(2560): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2859)
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 dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125)
10-28 18:09:31.613: E/AndroidRuntime(2560): at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
10-28 18:09:31.613: E/AndroidRuntime(2560): at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
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): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2672)
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">
<activity android:label="@string/app_name" android:screenOrientation="landscape" android:launchMode="singleTask" android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale|layoutDirection|density" android:hardwareAccelerated="false" android:name="com.companyname.glass.screen.UnityPlayerActivity">
<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'
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.
Answered by Justin Markwell on January 7, 2022
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP