1

I've updated the react-native from 0.27 to 0.35. After installing the release.apk to my device, I was only able to start it with adb shell.

The installation does not create a 'desktop' icon on the phone(yes the png-s are placed properly), and in the settings/application manager, even though I can find my app and all of the infos about it, I cannot launch it by its mainActivity.

Any ideas?

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="my.pckg.name"
android:versionCode="1"
android:versionName="1.0">

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.CALL_PHONE"/>

<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>


<uses-sdk
    android:minSdkVersion="16"
    android:targetSdkVersion="22" />

<application
  android:name=".MainApplication"
  android:allowBackup="true"
  android:label="@string/app_name"
  android:icon="@mipmap/ic_launcher"
  android:theme="@style/AppTheme">
    <activity
            android:name=".MainActivity"
            android:label="@string/app_name"
            android:screenOrientation="portrait"
                   android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
            android:launchMode="singleTop">

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.LAUNCHER" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />  
            <data android:scheme="http"
                  android:host="my.website.for.DeepLink"
                  android:pathPrefix="/#/register_login/status=successful" />          
        </intent-filter>          
    </activity>
</application></manifest>

MainActivity:

package my.pckg.name;
import com.facebook.react.ReactActivity;
public class MainActivity extends ReactActivity {
/**
 * Returns the name of the main component registered from JavaScript.
 * This is used to schedule rendering of the component.
 */
@Override
protected String getMainComponentName() {
    return "pckgName";
}}

MainApplication:

package my.pckg.name;

import android.app.Application;
import android.util.Log;

import com.facebook.react.ReactApplication;
import com.facebook.react.ReactInstanceManager;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
//... other stuff
import java.util.Arrays;
import java.util.List;

public class MainApplication extends Application implements ReactApplication    {

private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@Override
protected boolean getUseDeveloperSupport() {
  return BuildConfig.DEBUG;
}

@Override
protected List<ReactPackage> getPackages() {
  return Arrays.<ReactPackage>asList(
      new MainReactPackage(),
      //.... other stuff
  );
}
};

  @Override
  public ReactNativeHost getReactNativeHost() {
      return mReactNativeHost;
  }
}
ddobby94
  • 273
  • 4
  • 12

2 Answers2

9

Just figured it out:

The problem was within the mainActivity tag. You need to separate the inner content of your MainActivity with an < intent-filter> tag.

Before:

  <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.LAUNCHER" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />  
        <data android:scheme="http"
              android:host="my.website.for.DeepLink"
              android:pathPrefix="/#/register_login/status=successful" />          
    </intent-filter>       

After (the working one):

   <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
   </intent-filter>
   <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />  
        <data android:scheme="http"
              android:host="my.website.for.DeepLink"
              android:pathPrefix="/#/register_login/status=successful" />          
    </intent-filter>       

More info: https://developer.android.com/guide/components/intents-filters.html#imatch

ddobby94
  • 273
  • 4
  • 12
1

You have to define your Launcher Activity in Android Manifest.

   <activity android:name=".example.Main">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
SamuelPS
  • 555
  • 6
  • 20