React-Native productFlavors (Error type 3: Activity class does not exist)

前端 未结 6 2403
粉色の甜心
粉色の甜心 2021-02-20 06:50

I want to use 2 productFlavors for my Android App: live and staging.

In app/build.grandle I defined them like this: <

相关标签:
6条回答
  • 2021-02-20 07:14

    Uninstall the app from the device using:

    cd android && ./gradlew uninstallAll
    

    Then run the app again using:

    react-native start
    react-native run-android
    
    0 讨论(0)
  • 2021-02-20 07:16

    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

    0 讨论(0)
  • 2021-02-20 07:16

    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
    
    0 讨论(0)
  • 2021-02-20 07:20

    Try giving resValue like this:

    staging { applicationId "com.some.id.staging" resValue "string", "build_config_package", "com.some.id" }

    0 讨论(0)
  • 2021-02-20 07:33

    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
    
    0 讨论(0)
  • 2021-02-20 07:38

    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.

    0 讨论(0)
提交回复
热议问题