今天我有一个源项目,并且在尝试同步时收到此错误
所有风味现在必须属于命名的风味维度
我的产品具有模块等级的味道
productFlavors { armv7 { ndk { abiFilter "armeabi-v7a" } versionCode = 1 } }
我尝试将这些代码放在上面
flavorDimensions“默认”
flavorDimensions“ versionCode”
我的build.gradle代码:
apply plugin: 'com.android.application' repositories { mavenCentral() jcenter() maven { url "https://jitpack.io" } } configurations { implementation.exclude module: 'support-v4' } dependencies { implementation 'com.google.android.gms:play-services-gcm:10.2.0' implementation 'com.google.android.gms:play-services-maps:10.2.0' implementation 'com.google.android.gms:play-services-vision:10.2.0' implementation 'com.android.support:support-core-ui:25.3.1' implementation 'com.android.support:support-compat:25.3.1' implementation 'com.android.support:support-core-utils:25.3.1' implementation 'com.android.support:support-v13:25.3.1' implementation 'com.android.support:palette-v7:25.3.1' implementation 'net.hockeyapp.android:HockeySDK:4.1.2' implementation 'com.googlecode.mp4parser:isoparser:1.0.6' implementation 'com.stripe:stripe-android:2.0.2' // telegraf implementation 'com.android.support:multidex:1.0.1' implementation 'com.android.support:design:25.3.1' implementation 'com.android.support:cardview-v7:25.3.1' implementation files('libs/android-viewbadger.jar') implementation files('libs/ksoap2-android-assembly-3.1.1-jar-with-dependencies.jar') // implementation 'co.ronash.android:pushe-base:1.2.0' implementation 'com.onesignal:OneSignal:3.+@aar' implementation 'com.github.QuadFlask:colorpicker:0.0.12' // Download, Catch, Etc... Images implementation 'com.squareup.picasso:picasso:2.5.2' } android { compileSdkVersion 27 buildToolsVersion '27.0.3' useLibrary 'org.apache.http.legacy' defaultConfig.applicationId = "ir.imodares.telegraf" defaultConfig.manifestPlaceholders = [onesignal_app_id : "639e4454-4b40-4b07-a35d-eb24786b14bf", // Project number pulled from dashboard, local value is ignored. onesignal_google_project_number: "1039318212221"] sourceSets.main.jniLibs.srcDirs = ['./jni/'] externalNativeBuild { ndkBuild { path "jni/Android.mk" } } dexOptions { jumboMode = true } lintOptions { checkReleaseBuilds false // Or, if you prefer, you can continue to check for errors in release builds, // but continue the build even when errors are found: abortOnError false } compileOptions { sourceCompatibility JavaVersion.VERSION_1_7 targetCompatibility JavaVersion.VERSION_1_7 } signingConfigs { debug { storeFile file("config/release.keystore") storePassword "PASS" keyAlias "KEY" keyPassword "PASS" v2SigningEnabled false } release { storeFile file("config/release.keystore") storePassword "PASS" keyAlias "KEY" keyPassword "PASS" v2SigningEnabled false } } buildTypes { debug { debuggable true jniDebuggable true signingConfig signingConfigs.debug } release { debuggable false jniDebuggable false signingConfig signingConfigs.release minifyEnabled true shrinkResources false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } foss { debuggable false jniDebuggable false signingConfig signingConfigs.release } } defaultConfig.versionCode = 2000 sourceSets.debug { manifest.srcFile 'config/debug/AndroidManifest.xml' } sourceSets.release { manifest.srcFile 'config/release/AndroidManifest.xml' } sourceSets.foss { manifest.srcFile 'config/foss/AndroidManifest.xml' } productFlavors { armv7 { ndk { abiFilter "armeabi-v7a" } versionCode = 1 } } applicationVariants.all { variant -> def abiVersion = variant.productFlavors.get(0).versionCode variant.mergedFlavor.versionCode = defaultConfig.versionCode * 10 + abiVersion } defaultConfig { minSdkVersion 16 targetSdkVersion 27 versionName "3.18.0" multiDexEnabled true externalNativeBuild { ndkBuild { arguments "NDK_APPLICATION_MK:=jni/Application.mk", "APP_PLATFORM:=android-16" abiFilters "armeabi-v7a", "x86" } } } } apply plugin: 'com.google.gms.google-services'
答案 0 :(得分:0)
请参见https://developer.android.com/studio/build/build-variants#product-flavors。
如果您声明多个风味,则必须为 armv7 维度明确命名风味。但是在这里,您不需要多个:
flavorDimensions "single-dimension-name-does-not-matter"
productFlavors {
armv7 {
ndk {
abiFilter "armeabi-v7a"
}
versionCode = 1 + defaultConfig.versionCode * 10
}
all {
versionCode = defaultConfig.versionCode * 10
}
}
现在您将获得6个APK:
telegraf-armv7-debug
,telegraf-armv7-release
,telegraf-armv7-foss
,telegraf-all-debug
,telegraf-all-release
,telegraf-all-foss
带有适当的版本代码。您无需手动使用 applicationVariants 。
表面上,您实际上根本不需要口味来完成任务。您可以使用splits。在这种情况下,您需要 applicationVariants 来正确设置 versionCode ;)