React Native app won't start when using applicationIdSuffix
What Im using for React Native 0.60+ with multiple build configurations
In my app/bundle.gradle
file I have the following configuration
productFlavors {
dev {
applicationId "com.my.app.development"
dimension "standard"
}
production {
applicationId "com.my.app"
dimension "standard"
}
}
buildTypes {
release {
// your release build values
}
debug {
// your debug build values
debuggable true
}
}
For a standard debug build
react-native run-android --variant devDebug --appIdSuffix \"development\"
For a Staging build (dev variables, but built for release)
react-native run-android --variant devRelease --appIdSuffix \"development\"
For a Release build
react-native run-android --variant productionRelease
this worked for me on react-native 0.50.3
react-native run-android --appIdSuffix "debug"
From the link above, it's been discussed for a long time (over a year) on github, and there seems to be a few patches on their way, so my fix below may or may not work depending on the version of react-native
you're using.
Here's how I've (temporarily) solved the issue. The problem is that react-native-cli
tries to call adb shell am start
with the wrong argument:
com.packagename/com.packagename.MainActivity
when it should be calling something like
com.packagename.debug/com.packagename.MainActivity
So until your version of react-native
is fixed, you can use this command (as recommended in this code-push PR:
cd android && ./gradlew installDebug && adb -s <DEVICE_ID> shell am start -n com.packageName.debug/com.packageName.MainActivity
It's not a perfect fix, but there's a patch on github which does essentially the same thing (in relation to a couple of issues and pull requests here & here).
If you have a custom applicationId (different from your Java package name), you have to specify it when running the run-android
command
npx react-native run-android --appId com.custompackagename.debug
You will see the result at the end when react is starting the intent
Starting: Intent { cmp=com.custompackagename.debug/com.packagename.MainActivity