2017-05-10 54 views
1

我是Android Studio新手。我现在正在使用它,希望获得一些错误消息,这将解释为什么我的APK无法在Blue Stacks中运行。 APK建立在Unity中。运行应用程序时出错:未找到默认活动

安装Android Studio,电话模拟器等后,我仍然无法运行APK。它说:

Error running app: Default Activity not found 

已经有a post有关此错误的堆栈溢出。不过,我的AndroidManifest.xml看起来很好。我也试过'无效缓存/重启'无济于事。当我去编辑配置>启动选项>指定的活动,我看不到任何活动供我选择。

下面是我的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> 

enter image description here

我应该怎么做才能运行APK?

* UPDATE *

我不知道如果这有助于。当我跑“分析APK ...”,我得到了以下内容:enter image description here

*更新2 * 还有一个红色的感叹号我旁边的Android Studio中体现其内容“URI未注册。 ”,指着这行:

xmlns:android="http://schemas.android.com/apk/res/android" 
+0

您是否有任何删除的活动可能仍然存在于清单中? –

+0

你是什么意思?我不这么认为。我根本没有触及过舱单。 –

+0

不,我的意思是你可能已经删除了一些活动,但忘记在清单文件中删除它们。就我个人而言,我没有这样的问题 –

回答

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的设备上运行。

+0

请忍受我这一点,但有没有办法来修改直接显示?我拥有的只是一个APK文件。 –

0

尝试将此代码添加到您的清单:

<category android:name="android.intent.category.LAUNCHER" /> 
0
<activity 
     android:name="FULL_NAME_OF_YOUR_ACTIVITY" 
     android:label="@string/app_name" > 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 

      <category android:name="android.intent.category.LAUNCHER"/> 
     </intent-filter> 
    </activity> 

这应该之间插入:

<application> </application> 

没有必要为无效缓存和重新启动。

相关问题