我是Android Studio新手。我现在正在使用它,希望获得一些错误消息,解释为什么我的APK无法在Blue Stacks中运行。 APK是在Unity中构建的。
安装Android Studio,手机模拟器等后,我仍然无法运行APK。它说:
Error running app: Default Activity not found
Stack Overflow中有关于此错误的a post。但是,我的AndroidManifest.xml看起来很好。我也试过“使高速缓存/重新启动无效”#39;无济于事。当我去编辑配置>启动选项>指定的活动,我看不到任何活动供我选择。
以下是我的AndroidManifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
android:theme="@ref/0x01030006"
android:versionCode="91"
android:versionName="91"
android:installLocation="2"
package="com.quizjungle.android"
platformBuildVersionCode="25"
platformBuildVersionName="7.1.1">
<supports-screens
android:anyDensity="true"
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true" />
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="25" />
<application
android:label="@ref/0x7f060050"
android:icon="@ref/0x7f02004c"
android:debuggable="false"
android:banner="@ref/0x7f02004b"
android:isGame="true">
<activity
android:label="@ref/0x7f060050"
android:name="com.unity3d.player.UnityPlayerNativeActivity"
android:launchMode="2"
android:screenOrientation="1"
android:configChanges="0x40000fff">
<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>
<meta-data
android:name="unityplayer.UnityActivity"
android:value="true" />
<meta-data
android:name="unityplayer.ForwardNativeEventsToDalvik"
android:value="true" />
</activity>
<activity
android:theme="@ref/0x01030011"
android:name="com.facebook.unity.FBUnityLoginActivity"
android:configChanges="0x40000fff" />
<activity
android:theme="@ref/0x01030011"
android:name="com.facebook.unity.FBUnityDialogsActivity"
android:configChanges="0x40000fff" />
<activity
android:name="com.facebook.unity.FBUnityAppLinkActivity"
android:exported="true" />
<activity
android:name="com.facebook.unity.FBUnityDeepLinkingActivity"
android:exported="true" />
<activity
android:name="com.facebook.unity.FBUnityGameRequestActivity" />
<activity
android:name="com.facebook.unity.FBUnityCreateGameGroupActivity" />
<activity
android:name="com.facebook.unity.FBUnityJoinGameGroupActivity" />
<activity
android:name="com.facebook.unity.AppInviteDialogActivity" />
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="1479999760.000000" />
<provider
android:name="com.facebook.FacebookContentProvider"
android:exported="true"
android:authorities="com.facebook.app.FacebookContentProvider365740347105248" />
<activity
android:theme="@ref/0x01030011"
android:name="com.chartboost.sdk.CBImpressionActivity"
android:excludeFromRecents="true"
android:configChanges="0x4a0"
android:hardwareAccelerated="true" />
<meta-data
android:name="com.google.android.gms.version"
android:value="@ref/0x7f050000" />
<activity
android:theme="@ref/0x7f08000f"
android:name="com.facebook.FacebookActivity"
android:configChanges="0x5b0" />
<activity
android:name="com.facebook.CustomTabActivity"
android:exported="true" />
<activity
android:name="com.facebook.CustomTabMainActivity" />
<service
android:name="com.google.android.gms.measurement.AppMeasurementService"
android:enabled="true"
android:exported="false" />
<receiver
android:name="com.google.android.gms.measurement.AppMeasurementReceiver"
android:enabled="true"
android:exported="false" />
<receiver
android:name="com.google.android.gms.measurement.AppMeasurementInstallReferrerReceiver"
android:permission="android.permission.INSTALL_PACKAGES"
android:enabled="true">
<intent-filter>
<action
android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
<provider
android:name="com.google.firebase.provider.FirebaseInitProvider"
android:exported="false"
android:authorities="com.quizjungle.android.firebaseinitprovider"
android:initOrder="100" />
<service
android:name="com.google.firebase.iid.FirebaseInstanceIdService"
android:exported="true">
<intent-filter
android:priority="-500">
<action
android:name="com.google.firebase.INSTANCE_ID_EVENT" />
</intent-filter>
</service>
<receiver
android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver"
android:permission="com.google.android.c2dm.permission.SEND"
android:exported="true">
<intent-filter>
<action
android:name="com.google.android.c2dm.intent.RECEIVE" />
<action
android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category
android:name="com.quizjungle.android" />
</intent-filter>
</receiver>
<receiver
android:name="com.google.firebase.iid.FirebaseInstanceIdInternalReceiver"
android:exported="false" />
<activity
android:theme="@ref/0x01030011"
android:name="com.unity.purchasing.googleplay.PurchaseActivity"
android:configChanges="0x40000fff" />
<activity
android:theme="@ref/0x0103000f"
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="0xfb0" />
<activity
android:theme="@ref/0x7f080000"
android:name="com.google.android.gms.ads.purchase.InAppPurchaseActivity" />
<activity
android:theme="@ref/0x01030010"
android:name="com.google.android.gms.common.api.GoogleApiActivity"
android:exported="false" />
</application>
<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.android.permission.READ_PHONE_STATE" />
<uses-permission
android:name="android.permission.WAKE_LOCK" />
<permission
android:name="com.quizjungle.android.permission.C2D_MESSAGE"
android:protectionLevel="0x2" />
<uses-permission
android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission
android:name="com.quizjungle.android.permission.C2D_MESSAGE" />
<uses-permission
android:name="com.android.vending.BILLING" />
<uses-feature
android:glEsVersion="0x20000" />
<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>
我该怎么做才能运行APK?
*更新*
我不知道这是否有帮助。当我跑步&#39;分析APK ...&#39;时,我得到以下内容:
*更新2 * Android Studio中的清单旁边还有一个红色感叹号,上面写着“URI未注册。”#,指向此行:
xmlns:android="http://schemas.android.com/apk/res/android"
答案 0 :(得分:1)
尝试将此代码添加到您的Manifest:
<category android:name="android.intent.category.LAUNCHER" />
答案 1 :(得分:0)
问题可能来自清单:不要为移动设备和电视机使用相同的启动器活动,而是尝试将它们分开(不太确定):
<application
...
<activity
android:name="com.example.android.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.android.TvActivity"
android:label="@string/app_name"
android:theme="@style/Theme.Leanback">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LEANBACK_LAUNCHER" /> <!-- See here ?-->
</intent-filter>
</activity>
</application>
您还应该声明LeanBack支持:
<manifest>
<uses-feature android:name="android.software.leanback"
android:required="false" />
...
</manifest>
将required
属性值设置为false
。如果将所需属性值设置为true
,则您的应用只能在使用Leanback UI的设备上运行。
答案 2 :(得分:0)
在活动xml中简单删除
参数
tools:context=".MainActivity"
干杯;)