[英]Android Studio Arctic Fox Flavor Dimension Issue
這是我第一次接觸風味維度。 我正在嘗試編譯現成的代碼,但不知何故我遇到了這個問題。
錯誤:
All flavors must now belong to a named flavor dimension. Learn more at https://d.android.com/r/tools/flavorDimensions-missing-error-message.html
Affected Modules: app
這是我的 build.gradle:app
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'com.google.gms.google-services'
id 'kotlin-kapt'
id 'com.google.firebase.crashlytics'
id 'kotlin-android-extensions'
id 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin'
}
android {
compileSdkVersion 31
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.adit.bangkit.plagroid"
minSdkVersion 23
targetSdkVersion 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary true
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures {
viewBinding true
dataBinding true
}
productFlavors {
sandbox {
buildConfigField "String", "BASE_URL", "\"https://plagro.000webhostapp.com/payment.php/\""
buildConfigField "String", "CLIENT_KEY", "\"SB-Mid-client-zS17TygMBI02Ta0o\""
}
production {
buildConfigField "String", "BASE_URL", "\"https://plagro.000webhostapp.com/payment.php/\""
buildConfigField "String", "CLIENT_KEY", "\"Mid-client-GtpJDccjfv7lVXis\""
}
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.4.1'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.1'
implementation 'androidx.navigation:navigation-fragment-ktx:2.4.1'
implementation 'androidx.navigation:navigation-ui-ktx:2.4.1'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.gms:play-services-maps:18.0.2'
implementation 'com.google.android.gms:play-services-location:19.0.1'
implementation 'com.google.firebase:firebase-database-ktx:20.0.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
//Firebase
implementation platform('com.google.firebase:firebase-bom:28.4.0')
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.google.firebase:firebase-auth-ktx'
implementation 'com.google.firebase:firebase-firestore-ktx'
implementation 'com.google.firebase:firebase-storage-ktx'
//glide
implementation 'com.github.bumptech.glide:glide:4.12.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
implementation 'com.jakewharton:butterknife:10.0.0'
kapt "com.jakewharton:butterknife-compiler:10.0.0"
annotationProcessor 'com.jakewharton:butterknife-compiler:10.0.0'
implementation 'de.hdodenhof:circleimageview:3.1.0'
implementation "androidx.core:core-ktx:1.7.0"
implementation 'com.loopj.android:android-async-http:1.4.9'
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2"
implementation 'androidx.preference:preference-ktx:1.2.0'
implementation "io.grpc:grpc-okhttp:1.32.2"
// KTX for the Maps SDK for Android
implementation 'com.google.maps.android:maps-ktx:3.2.1'
// (Optional) KTX for the Maps SDK for Android Utility Library
implementation 'com.google.maps.android:maps-utils-ktx:3.2.1'
implementation 'com.google.maps.android:android-maps-utils:2.2.3'
implementation 'com.firebase:geofire-android-common:3.1.0'
//midtrans payment
implementation 'com.midtrans:uikit:1.28.0-SANDBOX'
}
很抱歉我是菜鳥,真的不知道如何解決這個問題。 如果有人有解決方案,請幫助我解決這個問題。這個問題發生在我添加 midtrans 支付庫之后。
如何解決這個問題?
根據錯誤中的鏈接,您應該添加一個風味維度。 根據該鏈接中的文檔
所有口味都必須屬於一個命名的口味維度,這是一組產品口味。 您必須將所有口味分配給一個口味維度; 否則,您將收到如下所示的構建錯誤。 如果給定的模塊僅指定一個風味維度,則 Android Gradle 插件會自動將模塊的所有風味分配給該維度。
在他們添加的鏈接示例中
flavorDimensions "version"
在下方,您可以在 productFlavor 標簽中添加
dimension "version"
或者,如果您不需要多個維度,則可以忽略最后一部分。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.