现在,所有风格都必须属于命名风味维度Android Studio NDK

知识养成了思想,思想同时又在融化知识。这篇文章主要讲述现在,所有风格都必须属于命名风味维度Android Studio NDK相关的知识,希望能为你提供帮助。
今天我有一个源项目,当我尝试同步时,我收到此错误

所有口味现在必须属于命名的风味维度
【现在,所有风格都必须属于命名风味维度Android Studio NDK】我的模块级产品
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'

My Project structure
My Project structure
My Project structure
My Project structure
答案见https://developer.android.com/studio/build/build-variants#product-flavors。
如果声明多个flavor,则必须明确指定armv7维度的flavor。但在这里你不需要多个:
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; )

    推荐阅读