I want to use 2 productFlavors
for my Android App: live
and staging
.
In app/build.grandle
I defined them like this: <
Uninstall the app from the device using:
cd android && ./gradlew uninstallAll
Then run the app again using:
react-native start
react-native run-android
Add the --appId
on run command, so the react native will know where to find the Main Activity:
react-native run-android --variant=stagingDebug --appId com.some.id.staging
Cause you change the applicationId in the productFlavors
, react-native-cli
can't recognize it. To fix, just add your changed appId when run start command
react-native run-android --variant=staging --appId com.some.id.staging
Try giving resValue
like this:
staging {
applicationId "com.some.id.staging"
resValue "string", "build_config_package", "com.some.id"
}
I had the same issue and I solve by adding the appIdSuffix
to the react-native
run command.
react-native run-android --variant variantDebug --appIdSuffix suffix
There is a pull request pending for React Native that will fix this issue.
Until then you can simply replace /node_modules/react-native/local-cli/runAndroid/runAndroid.js
with the runAndroid.js file from the pull request.