Mayank Baiswar
Mayank Baiswar

Reputation: 595

Two apps after react-native run-android

I'm making a react native app and earlier it was working fine but now when I run "react-native run-android", after the successful install and launch, I can see two apps in the simulator and both of them are working fine.
So, any ideas why I'm seeing 2 apps or should I say why I'm getting an extra duplicate app installed?

Upvotes: 18

Views: 8323

Answers (7)

Tochukwu Emmanuel
Tochukwu Emmanuel

Reputation: 1

All you need to simply do is checkout for

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

within the App AndroidManifest.xml file, there's more likely you have multiple launchers defined in your app's manifest file. You can try removing any extra launchers.

Try clearing the cache and rebuild your app.

Upvotes: 0

Chinedu Ofor
Chinedu Ofor

Reputation: 767

Change this

<activity
            android:name=".SplashActivity"
            android:theme="@style/SplashTheme"
            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=".MainActivity"
        android:label="@string/app_name"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
        android:windowSoftInputMode="adjustResize"
        android:exported="true"
      >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
      </activity>

To

<activity
            android:name=".SplashActivity"
            android:theme="@style/SplashTheme"
            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=".MainActivity"
        android:label="@string/app_name"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
        android:windowSoftInputMode="adjustResize"
        android:exported="true"
      />

Basically you have two intent-filters delete one

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

Upvotes: 7

Rajan Maharjan
Rajan Maharjan

Reputation: 4982

The problem is due to multiple category LAUNCHER in both splash and main activity.

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

The solution with both SplashActivity and MainActivity is to change

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

to

<category android:name="android.intent.category.DEFAULT" />

in MainActivity.

The file with both .SplashActivity and .MainActivity looks like this;

    <activity
        android:name=".SplashActivity"
        android:theme="@style/SplashTheme"
        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=".MainActivity"
        android:label="@string/app_name"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
        android:windowSoftInputMode="adjustResize"
        android:exported="true">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
        </intent-filter>
    </activity>

Upvotes: 18

Aras
Aras

Reputation: 1597

I think you added splash screen in your app after it you have this problem, first go to this Dir: android/app/src/main/AndroidManifest.xml if you add two time something like this

       <activity
        android:name=".SplashActivity"
        android:theme="@style/SplashTheme"
        android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        </activity> -->

it will render two times and build two apps on your device.

in my file

AndroidManifest.xml

<!-- remove just first part the activity, but i comment this part -->

  <!-- <activity
    android:name=".SplashActivity"
    android:theme="@style/SplashTheme"
    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=".MainActivity"
    android:label="@string/app_name"
    android:theme="@style/SplashTheme"
    android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
    android:windowSoftInputMode="adjustResize">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
  </activity>

Upvotes: 28

MattyCodes
MattyCodes

Reputation: 191

To add to the answer Aras posted above, for me the issue was specifically with the extra intent-filter attributes which were labeled 'MAIN' and 'LAUNCHER'. You can't have more than one occurrence of those without creating duplicate apps, it seems.

       <activity
         android:name=".SplashActivity"
         android:theme="@style/SplashTheme"
         android:label="@string/app_name">
         <!-- You'll either want to remove this section, or ensure that it does not exist in any other activities. -->
         <intent-filter>
           <action android:name="android.intent.action.MAIN" />
           <category android:name="android.intent.category.LAUNCHER" />
         </intent-filter>
       </activity>

Upvotes: 2

PeaceDefener
PeaceDefener

Reputation: 638

I had this issue as well. It turns out one of RN lib I installed created an extra <activity /> and <intent-filter />tags. Just check your AndroidManifest.xml.

My source: Running app gives 2 app icons in Android Studio - newbie

Upvotes: 7

Rodrigo Gontijo
Rodrigo Gontijo

Reputation: 587

Check the package name of the installed apps.

Upvotes: -2

Related Questions