我想将 2productFlavors
用于我的 Android 应用程序:live
和staging
.
在app/build.grandle
我这样定义它们:
defaultConfig {
applicationId "com.some.id"
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
splits {...}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
debug {
debuggable true
minifyEnabled false
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
productFlavors {
live {
applicationId "com.some.id"
}
staging {
applicationId "com.some.id.staging"
}
}
}
现在,当我运行时react-native run-android --variant=liveDebug
一切正常,但是当我尝试运行时,react-native run-android --variant=stagingDebug
我得到了错误:
Installed on 1 device.
BUILD SUCCESSFUL
Total time: 11.824 secs
Starting the app on 192.168.56.101:5555 (/usr/local/opt/android-sdk/platform-tools/adb -s 192.168.56.101:5555 shell am start -n com.somepackage/.MainActivity)...
Starting: Intent { cmp=com.somepackage/.MainActivity }
Error type 3
Error: Activity class {com.somepackage/com.somepackage.MainActivity} does not exist.
正如输出所说,该应用程序已安装在设备上,但为什么它说不MainActivity
存在?我想这是由于不同的 applicationId 尽管根据本指南它是正确的
我该如何解决这个问题?
提前致谢!