2

I am new to Android Studio. I am using it now in the hope of obtaining some error messages that will explain why my APK couldn't be run in Blue Stacks. The APK was built in Unity.

After installing Android Studio, a phone emulator etc, I still couldn't run the APK. It said:

Error running app: Default Activity not found

There has been a post about this error in Stack Overflow. However, my AndroidManifest.xml looks fine to me. I have also tried 'Invalidate Caches / Restart' to no avail. When I went to Edit Configurations > Launch Options > Specified Activity, I could not see any activity for me to select.

Below is my 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

What should I do to run the APK?

* UPDATE *

I don't know if this helps. When I ran 'Analyze APK...', I got the following:enter image description here

* Update 2 * There is also a red exclamation sign next to my manifest in Android Studio which reads 'URI is not registered.', pointing to this line:

xmlns:android="http://schemas.android.com/apk/res/android"
Community
  • 1
  • 1
Chong Lip Phang
  • 8,755
  • 5
  • 65
  • 100
  • Do you have any deleted activity that may still be present in the manifest? – esQmo_ May 10 '17 at 23:46
  • What do you mean? I don't think so. I have not touched the manifest at all. – Chong Lip Phang May 10 '17 at 23:47
  • No, I mean you may have deleted some activities but forgot to delete them in the manifest file. Personally, I haven't had such problem – esQmo_ May 10 '17 at 23:49
  • Actually Unity prepared that APK file for me. So I have no way of answering your question. I have another APK which gave me the same error in Android Studio, but it could be run in Blue Stacks. – Chong Lip Phang May 10 '17 at 23:51
  • Did you try the solution from here : http://stackoverflow.com/questions/18828654/default-activity-not-found-in-android-studio – esQmo_ May 10 '17 at 23:57

3 Answers3

1

Try adding this code to your Manifest:

<category android:name="android.intent.category.LAUNCHER" />
Koby Douek
  • 16,156
  • 19
  • 74
  • 103
0

The issue may come from the manifest: Instead of having the same launcher activity for mobile and TV, try separate them like this (not really sure though):

<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>

You should also declare LeanBack support:

<manifest>
    <uses-feature android:name="android.software.leanback"
        android:required="false" /> 
    ...
</manifest>

Set the required attribute value to false. If you set the required attribute value to true, your app will run only on devices that use the Leanback UI.

esQmo_
  • 1,464
  • 3
  • 18
  • 43
-1

Simple delete in your activity xml

activity_main.xml

parameter

tools:context=".MainActivity"

Cheers;)

Iefimenko Ievgen
  • 379
  • 1
  • 5
  • 12