gpt4 book ai didi

android - 使用Flavors使用React Native和Android创建不同的apk

转载 作者:行者123 更新时间:2023-12-03 04:29:14 29 4
gpt4 key购买 nike

我试图在使用React Native编写的Android应用中使用 flavor 来创建不同的APK,但是在运行.gradlew assembleRelease或任何其他组合时出现以下错误:

Could not find method applicationIdSuffix() for arguments [.free] on ProductFlavor_Decorated{name=free, dimension=null, minSdkVersion=null, targetSdkVersion=null, renderscriptTargetApi=null, renderscriptSupportModeEnabled=null, renderscriptNdkModeEnabled=null, versionCode=null, versionName=null, applicationId=null, testApplicationId=null, testInstrumentationRunner=null, testInstrumentationRunnerArguments={}, testHandleProfiling=null, testFunctionalTest=null, signingConfig=null, resConfig=null, mBuildConfigFields={}, mResValues={}, mProguardFiles=[], mConsumerProguardFiles=[], mManifestPlaceholders={}}.

enter image description here

当我删除 productFlavors时,构建过程可以正常工作。
build.gradle文件如下所示:
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"

defaultConfig {
applicationId "com.myapp"
minSdkVersion 16
targetSdkVersion 22
versionCode 27
versionName "3.3.1"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
productFlavors {
free {
applicationIdSuffix ".free"
}
pro {
applicationIdSuffix ".pro"
}
}
...
}
gradle-wrapper.properties的内容如下:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip

没有任何线索怎么了。知道我缺少什么吗?另外,我将 Webstorm用作IDE,因为我正在从事ReactNative项目,并且主要从事JS代码,如果我使用 AndroidStudio,事情会变得更容易,尤其是关于android配置

谢谢

最佳答案

将resValue行添加到“免费”版本中

productFlavors {
free {
applicationIdSuffix ".free"
resValue "string", "build_config_package", "com.your_package" // the package of your Android app
}
pro {
applicationIdSuffix ".pro"
}
}
...

关于android - 使用Flavors使用React Native和Android创建不同的apk,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41837796/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com