我设置了一个文件.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.
如何解决问题?