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
All flavors must belong to a named flavor dimension, which is a group
of product flavors. You must assign all flavors to a flavor dimension;
otherwise, you will get the build error shown below. If a given module
specifies only one flavor dimension, the Android Gradle plugin
automatically assigns all of the module's flavors to that dimension.
In the example from the link they add
flavorDimensions "version"
And below, in your productFlavor tags you could add
dimension "version"
Or if you don't need more than one dimension you can ignore this last part.
Related
I've benn programming my school proyect for several months and now im done. I used to compile my app directly to my phone (Android 12) but I need it to be at least API 28. I tried to change the Build Gradle target version from 31 to 28 but I'm having errors with the dependencies versions.
There is any safe and quick way to know which version exactly I need for each dependency?
Im currently using theese.
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
//Hilt
id 'kotlin-kapt'
id 'dagger.hilt.android.plugin'
}
android {
compileSdk 32
defaultConfig {
applicationId "com.kdapp.estudiapp"
minSdk 24
targetSdk 31
versionCode 1
versionName "1.1"
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 {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion compose_version
}
packagingOptions {
resources {
excludes += '/META-INF/{AL2.0,LGPL2.1}'
}
}
}
apply plugin: 'com.google.gms.google-services'
dependencies {
implementation 'androidx.core:core-ktx:1.7.0'
implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.material:material:$compose_version"
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
implementation 'androidx.activity:activity-compose:1.3.1'
implementation 'com.google.firebase:firebase-auth-ktx:21.0.6'
implementation 'com.google.firebase:firebase-firestore-ktx:24.2.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version"
//Firebase
implementation platform('com.google.firebase:firebase-bom:30.2.0')
implementation 'com.google.firebase:firebase-analytics-ktx'
implementation 'com.google.firebase:firebase-auth:21.0.6'
implementation 'com.google.android.gms:play-services-auth:20.2.0'
//Firebase -> Storage
implementation 'com.google.firebase:firebase-storage'
//Navigation
implementation 'androidx.navigation:navigation-compose:2.5.0'
// Coroutines
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.3.5"
// Hilt DI
def hilt_lifecycle_viewmodel = "1.0.0-alpha03"
def hilt_navigation = "1.0.0-alpha03"
implementation "com.google.dagger:hilt-android:$hilt_version"
kapt "com.google.dagger:hilt-android-compiler:$hilt_version"
implementation "androidx.hilt:hilt-lifecycle-viewmodel:$hilt_lifecycle_viewmodel"
implementation "androidx.hilt:hilt-navigation-compose:$hilt_navigation"
//GSON
implementation 'com.google.code.gson:gsoenter code heren:2.9.0'
}
Any external dependencies require version checks specified on their official GitHub repo, or their website, if it isn't open-source. Now, as of a quick way to downgrade minSdk, just press Ctrl+Alt+Shift+S within Android Studio, and it'll open the project structure dialog. Find a field that says minSdk, and set it to whatever you require. I recommend setting the targetSdk and compileSdk to the maximum value available, they won't affect your app's deployment on lower api devices. There's also a suggestions pane in the dialog, which can help you update dependency versions studio deems to be out-dated. After having set everything, click Apply/Ok.
This error appears when I extract a file aab:
Invalid dex file indices, expecting file 'classesŁ¢.dex' but found 'classes2.dex'.
my Gradle app:
apply plugin: 'com.android.application'
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.rewardstom.win"
minSdkVersion 19
multiDexEnabled true
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
lintOptions {
checkReleaseBuilds false
}
dexOptions {
javaMaxHeapSize "4g"
preDexLibraries = false
}
}
dependencies {
implementation 'com.android.support:multidex:1.0.3'
implementation 'androidx.multidex:multidex:2.0.1'
implementation fileTree(dir: 'libs', include: ['*.aar', '*.jar'])
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'androidx.palette:palette:1.0.0'
implementation 'com.android.volley:volley:1.2.0'
implementation 'com.facebook.android:facebook-login:7.1.0'
implementation platform('com.google.firebase:firebase-bom:28.2.0')
implementation 'com.google.firebase:firebase-auth'
implementation 'com.google.firebase:firebase-messaging'
implementation 'com.google.android.gms:play-services-auth:19.2.0'
implementation 'com.google.firebase:firebase-dynamic-links'
implementation "androidx.browser:browser:1.3.0"
//Ads
implementation 'com.google.android.gms:play-services-ads:20.2.0'
implementation 'com.google.android.gms:play-services-ads-identifier:17.0.1'
implementation 'com.google.android.gms:play-services-basement:17.6.0'
api 'com.tapjoy:tapjoy-android-sdk:12.8.0#aar'
implementation 'com.fyber:offerwall-sdk:9.2.2'
implementation 'com.applovin:applovin-sdk:10.2.1'
implementation 'com.adcolony:sdk:4.5.0'
implementation 'com.chartboost:chartboost-sdk:8.2.0'
implementation 'com.ironsource.sdk:mediationsdk:7.1.7'
implementation 'com.github.vungle:vungle-android-sdk:6.7.1'
implementation 'com.facebook.android:audience-network-sdk:6.5.1'
//noinspection GradleDependency
implementation 'commons-io:commons-io:2.4'
}
apply plugin: 'com.google.gms.google-services'
One temporary solution that may work is to set
release {
minifyEnabled false
.......
}
This will reduce your app size which may cause it to use only one dex file.
If this didn't work, you need to change your Windows display language to a language that uses. Arabic Numerals (including your Administrative language settings).
import javax.swing.* is showing unresolved reference to import i have tried to do some google searches and youtube but no result also tried to search for some dependencies
build.gradle:-
`plugins {
id 'com.android.application'
id 'kotlin-android'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.example.example"
minSdkVersion 18
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
packagingOptions {
pickFirst 'androidsupportmultidexversion.txt'
}
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
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.5.0'
implementation 'com.android.support:multidex:1.0.3'
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'com.intellij:forms_rt:7.0.3'
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.5'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation platform('com.google.firebase:firebase-bom:28.0.1')
implementation 'com.google.firebase:firebase-auth-ktx'
implementation 'com.google.firebase:firebase-core:19.0.0'
implementation 'com.android.support:multidex:1.0.3'
}`
You can NOT use Swing in Android
This is because Swing is developed for Java SE, while Android is based on Android's own implementation of Java. Since both Java implementations differ, you cannot use Swing in Android.
Instead, use the UI components provided by Android to build your app's UI. You can follow this guide to build a simple UI.
PS: If you are curious of how both Java differ, you can read this.
It's my first time building AAR
The official site says that All I hate to do is build APK and AAR will be assembled
Here's the quote:
But when I choose "Build Apk(s)" nothing happens.
Another tutorial says I have to choose Gradle-> library name -> tasks-> build-> :assembleRelease.
But there is no such thing :
How can I assemble library as AAR?
here's my gradle :
plugins {
id 'com.android.library'
id 'kotlin-android'
id 'kotlin-kapt'
}
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
minSdkVersion 17
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
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'
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.1'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
def room_version = "2.2.3"
implementation "androidx.room:room-runtime:$room_version"
kapt "androidx.room:room-compiler:$room_version"
implementation "androidx.room:room-ktx:$room_version"
implementation "androidx.room:room-rxjava2:$room_version"
implementation 'com.google.code.gson:gson:2.8.2'
}
Just click assemble or add buildTypes.debug. While you don't have buildTypes.debug defined, it won't generate the tasks you are looking for (as there only is one configuration present there and so there is nothing to tell apart).
I am uploading android app bundle on Google Play Store but getting 64-bit requirement error on review.My app bundle is completely Java/Kotlin based with native support as some third party has dependency on it.
I have included the support for all architecture armeabi-v7a, arm64-v8a,x86,x86_64 in gradle file also enabled split for the abi.
Gradle config I have added:
apply plugin: "com.android.application"
apply plugin: "io.fabric"
apply plugin: 'com.google.gms.google-services'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'com.google.firebase.firebase-perf'
apply from: '../jacoco.gradle'
def appCenterKey = "\"XXXX\""
android {
signingConfigs {
release {
keyAlias 'XXXX'
keyPassword 'XXXX'
storeFile file('../buildconfig/XXXXX.jks')
storePassword 'XXXXX'
}
}
compileSdkVersion 28
defaultConfig {
applicationId "com.XXXXX.XXXX"
minSdkVersion 23
targetSdkVersion 28
versionCode 504
versionName "2.0.0"
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
ndk {
abiFilters "armeabi-v7a", "arm64-v8a","x86","x86_64"
}
}
buildTypes {
all {
buildConfigField "String", XXXXX,appCenterKey
}
debug {
applicationIdSuffix '.dev'
versionNameSuffix '-DEV'
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
testOptions {
execution 'ANDROIDX_TEST_ORCHESTRATOR'
animationsDisabled true
unitTests {
includeAndroidResources = true
returnDefaultValues = true
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
bundle {
language {
enableSplit = true
}
density {
enableSplit = true
}
abi {
enableSplit = true
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.browser:browser:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation "junit:junit:4.12"
androidTestImplementation 'androidx.test:runner:1.2.0'
// Mockito
def mockitoVersion = "2.17.0"
testImplementation "org.mockito:mockito-core:$mockitoVersion"
androidTestImplementation "org.mockito:mockito-android:$mockitoVersion"
// App Center dependencies
def appCenterVersion = "1.4.0"
implementation "com.microsoft.appcenter:appcenter-analytics:$appCenterVersion"
implementation "com.microsoft.appcenter:appcenter-crashes:$appCenterVersion"
// GSON (https://github.com/google/gson)
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'org.danilopianini:gson-extras:0.2.1'
// Picasso (http://square.github.io/picasso/)
implementation "com.squareup.picasso:picasso:2.71828"
implementation 'androidx.exifinterface:exifinterface:1.0.0'
// Google Play Services
def googlePlayVersion = "17.0.0"
implementation "com.google.android.gms:play-services-maps:$googlePlayVersion"
implementation "com.google.android.gms:play-services-location:$googlePlayVersion"
// AWS (Cognito, API Gateway, etc.)
def awsVersion = "2.14.2"
implementation("com.amazonaws:aws-android-sdk-auth-userpools:$awsVersion#aar") {
transitive = true
}
implementation("com.amazonaws:aws-android-sdk-mobile-client:$awsVersion#aar") {
transitive = true
}
implementation "com.amazonaws:aws-android-sdk-apigateway-core:$awsVersion"
implementation "com.amazonaws:aws-android-sdk-kinesis:$awsVersion"
// For amazon web hosted UI authorization
implementation("com.amazonaws:aws-android-sdk-cognitoauth:$awsVersion#aar") {
transitive = true
}
// Adapter Delegates (https://github.com/sockeqwe/AdapterDelegates)
implementation 'com.hannesdorfmann:adapterdelegates3:3.0.1'
implementation 'com.squareup.retrofit2:retrofit:2.5.0'
implementation 'com.squareup.retrofit2:converter-gson:2.5.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.10.0'
//Dagger 2
implementation 'com.google.dagger:dagger:2.16'
kapt "com.google.dagger:dagger-compiler:2.16"
//Permissions
def permissionsVersion = "3.3.1"
implementation("com.github.hotchemi:permissionsdispatcher:$permissionsVersion") {
exclude module: "support-v13"
}
kapt "com.github.hotchemi:permissionsdispatcher-processor:3.3.1"
// Braintree - (Suppressing Lint warning as the Braintree docs ask for dynamic version)
//noinspection GradleDynamicVersion
implementation 'com.braintreepayments.api:drop-in:3.7.0'
//Circular ImageView
implementation 'de.hdodenhof:circleimageview:2.2.0'
//Calligraphy
implementation 'io.github.inflationx:calligraphy3:3.0.0'
implementation 'io.github.inflationx:viewpump:1.0.0'
// Animated Gif
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.16'
//Image Compressor
implementation 'id.zelory:compressor:2.1.0'
// Firebase
implementation "com.google.firebase:firebase-core:17.0.1"
implementation "com.google.firebase:firebase-perf:18.0.1"
implementation 'com.google.firebase:firebase-messaging:19.0.1'
implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
testImplementation 'com.nhaarman.mockitokotlin2:mockito-kotlin:2.0.0-RC2'
implementation 'com.airbnb.android:lottie:2.7.0'
// Google vision API for Face Detection
implementation 'com.google.android.gms:play-services-vision:18.0.0'
// Google wallet for Google Pay
implementation 'com.google.android.gms:play-services-wallet:17.0.0'
// TODO Enable below line for this error for compile time error : Dagger2 cannot access nullable. javax.annotation.Nullable not found
// implementation 'com.google.code.findbugs:jsr305:3.0.2'
// QR and Barcode
implementation 'com.google.zxing:core:3.3.3'
//Multidex
implementation 'com.android.support:multidex:1.0.3'
}
repositories {
mavenCentral()
}
While creating a signed app bundle, in the analyzer it shows all the native support library in it(.so file under armeabi-v7a, arm64-v8a,x86,x86_64 in lib folder).
But when I upload this bundle to playstore it uploads successfully but shows support for only 2 platforms(32-bit) which is armeabi-v7a, x86. Instead it should have shown support for all platform both 64 and 32 bit.
On click of review it shows me error message
The following APKs or App Bundles are available to 64-bit devices, but they only have 32-bit native code.
Even though I have added dependency for both 32/64 bit native code.
you can verify add this code
defaultConfig {
....
renderscriptTargetApi 18
renderscriptSupportModeEnabled true
ndk.abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64', "armeabi"
}