Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 564
Mayank Baiswar Avatar asked Jul 19 '17 16:07

Mayank Baiswar


People also ask

Can you combine the native iOS and native Android code in React Native?

Yes, we can combine Android or iOS code in react native. React Native helps to smoothly combines the components written in Java, Objective-C or Swift.


2 Answers

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>
like image 89
Aras Avatar answered Sep 25 '22 05:09

Aras


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>
like image 36
Rajan Maharjan Avatar answered Sep 22 '22 05:09

Rajan Maharjan