It's my first encounter with flavor dimensions. I am trying to compile a ready-made code but somehow I ended up with this issue.
ERROR:
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
here is my 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'
}
I am sorry for being a noob and really don't know how to solve this. If someone had a solution please help me with this.this issue happend after i add midtrans payment library.
How to fix this?
According to the link from the error, you should add a flavour dimension. According to the documentation from that link
In the example from the link they add
And below, in your productFlavor tags you could add
Or if you don't need more than one dimension you can ignore this last part.