我用团结制作安卓游戏。我的apk版本中有错误。 我不知道如何解决它。我在下面附上了androidmanifest.xml和android日志。
的AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1" package="com.mycom.myapp" android:installLocation="auto">
<supports-screens android:anyDensity="true" android:largeScreens="true"
android:normalScreens="true" android:smallScreens="true"
android:xlargeScreens="true" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<application android:icon="@drawable/app_icon"
android:label="@string/app_name"
android:theme="@style/UnityThemeSelector"
android:debuggable="false" android:isGame="true">
<!-- Unity Activity-->
<activity android:label="@string/app_name"
android:name="com.unity3d.player.UnityPlayerActivity"
android:screenOrientation="sensorLandscape"
android:launchMode="singleTask" android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale">
<meta-data android:name="unityplayer.UnityActivity" android:value="true" />
<meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="true" />
<activity android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="@string/app_name" android:name="com.aoneg.unity.permissioncheck.PermissionRequestActivity"
android:screenOrientation="landscape" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
</intent-filter>
</activity>
<activity android:label="@string/app_name"
android:name="com.mycom.myapp.MainActivity"
android:screenOrientation="landscape">
</activity>
</application>
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="26" />
<uses-feature android:glEsVersion="0x00020000" />
<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>
android logcat错误
E/memtrack(4684): Couldn't load memtrack module (No such file or directory)
E/android.os.Debug(4684): failed to load memtrack module: -2
E/memtrack(4701): Couldn't load memtrack module (No such file or directory)
E/android.os.Debug(4701): failed to load memtrack module: -2
E/AndroidRuntime(4714): FATAL EXCEPTION: main
E/AndroidRuntime(4714): Process: com.mycom.myapp, PID: 4714
E/AndroidRuntime(4714): java.lang.RuntimeException: Unable to instantiate application com.mycom.myapp.MainActivity: java.lang.ClassCastException: com.mycom.myapp.MainActivity cannot be cast to android.app.Application
E/AndroidRuntime(4714): at android.app.LoadedApk.makeApplication(LoadedApk.java:516)
E/AndroidRuntime(4714): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4345)
E/AndroidRuntime(4714): at android.app.ActivityThread.access$1500(ActivityThread.java:135)
E/AndroidRuntime(4714): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
E/AndroidRuntime(4714): at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime(4714): at android.os.Looper.loop(Looper.java:136)
E/AndroidRuntime(4714): at android.app.ActivityThread.main(ActivityThread.java:5045)
E/AndroidRuntime(4714): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(4714): at java.lang.reflect.Method.invoke(Method.java:515)
E/AndroidRuntime(4714): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
E/AndroidRuntime(4714): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
E/AndroidRuntime(4714): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(4714): Caused by: java.lang.ClassCastException: com.mycom.myapp.MainActivity cannot be cast to android.app.Application
E/AndroidRuntime(4714): at android.app.Instrumentation.newApplication(Instrumentation.java:1007)
E/AndroidRuntime(4714): at android.app.Instrumentation.newApplication(Instrumentation.java:992)
E/AndroidRuntime(4714): at android.app.LoadedApk.makeApplication(LoadedApk.java:511)
E/AndroidRuntime(4714): ... 11 more
E/FastMixer(167): did not receive expected priority boost
E/BandwidthController(160): Updating quota globalAlert failed (No such file or directory)
E/Drm(167): Failed to open plugin directory /vendor/lib/mediadrm
E/BandwidthController(160): Updating quota globalAlert failed (No such file or directory)
非常感谢任何帮助/想法,谢谢!
答案 0 :(得分:0)
我认为您的MainActivity扩展了Application而不是Activity。在清单中使用应用程序标记。
希望它有所帮助。