1

我设置了一个文件.env.devdps

APP_NAME=TestDps

只需APP_NAME在 AndroidManifest.xml 中使用

<activity
  ...
  android:label="@string/APP_NAME"
/>

在我的android/app/build.gradle

defaultConfig {
  ...
  resValue "string", "build_config_package", "com.testdev"
  manifestPlaceholders = [label: 'testDev']
}

我添加了一个 buildTypesdps

buildTypes {
    debug {
        signingConfig signingConfigs.debug
        applicationIdSuffix ".dev"
    }
    release {
        // Caution! In production, you need to generate your own keystore file.
        // see https://reactnative.dev/docs/signed-apk-android.
        signingConfig signingConfigs.debug
        minifyEnabled enableProguardInReleaseBuilds
        proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
    }
    dps {
        initWith debug    
        applicationIdSuffix ".dps" 
        matchingFallbacks =  ['debug']
    }
}

然后在终端输入命令: ENVFILE=.env.devdps npx react-native run-android --variant=dps

结果显示错误Activity class {com.testdev/com.testdev.MainActivity} does not exist

BUILD SUCCESSFUL in 11s 46 actionable tasks: 46 executed info Connecting to the development server... info Starting the app on "emulator-5554"... Starting: Intent { cmp=com.testdev/.MainActivity } Error type 3 Error: Activity class {com.testdev/com.testdev.MainActivity} does not exist.

如何解决问题?

4

1 回答 1

1

检查 MainActivity.java 和 MainApplication.java 文件是否在正确的路径下。例如,如果你的 bundle id 是:com.companyname.app,它们应该在 android/app/src/main/java/com/companyname/app 下。还要检查您的 AndroidManifest.xml 中是否有正确的包,该包应该与您的包 ID 相同(在本示例中:com.companyname.app)。MainActivity 和 Mainapplication 文件中的包相同。

于 2021-08-04T07:52:29.867 回答