Error type 3. Activity class {com.awesome_project/ com.awesome_project.MainActivity} does not exist in react native (Android device)

后端 未结 24 1609
甜味超标
甜味超标 2021-01-30 20:10

I\'ve created the project using the following command.

react-native init Awesome_Project

I\'ve started the packager using the following com

24条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-30 20:35

    When working with react-native-config, I ran into this issue when using applicationIdSuffix with productFlavors.

    adding --appIdSuffix=[YOUR_FLAVOR] to my react-native run-android commands did the job. e.g

    ...
        flavorDimensions "env"
        productFlavors {
            dev {
                resValue "string", "app_name", "[DEV] My App"
                applicationIdSuffix ".dev"
            }
            staging {
                resValue "string", "app_name", "[STG] My App"
                applicationIdSuffix ".staging"
            }
            prod {
                resValue "string", "app_name", "My App"
            }
        }
    ...
    
    ...
    "scripts": {
        "android": "react-native run-android --variant=devDebug --appIdSuffix=dev",
        "android:staging": "react-native run-android --variant=stagingDebug --appIdSuffix=staging",
        "android:prod": "react-native run-android --variant=prodDebug",
        "android:staging:release": "react-native run-android --variant=stagingRelease --appIdSuffix=staging",
        "android:prod:release": "react-native run-android --variant=prodRelease",
    },
    ...
    

提交回复
热议问题