implementation 'com.jmedeisis:draglinearlayout:1.1.0' showing error - java

started a new blank template project and just after adding draglinearlayout dependency i started getting these errors, while before adding this dependency i ran my project and it worked fine. the error is as follows
Execution failed for task ':app:checkDebugDuplicateClasses'.
A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
Duplicate class android.support.v4.app.INotificationSideChannel found in modules core-1.5.0-runtime (androidx.core:core:1.5.0) and support-v4-22.1.1-runtime (com.android.support:support-v4:22.1.1)
Duplicate class android.support.v4.app.INotificationSideChannel$Stub found in modules core-1.5.0-runtime (androidx.core:core:1.5.0) and support-v4-22.1.1-runtime (com.android.support:support-v4:22.1.1)
Duplicate class android.support.v4.app.INotificationSideChannel$Stub$Proxy found in modules core-1.5.0-runtime (androidx.core:core:1.5.0) and support-v4-22.1.1-runtime (com.android.support:support-v4:22.1.1)
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
this is the error i'm getting
and this is my module grade file
plugins {
id 'com.android.application'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.ujjwal.drag_and_drop"
minSdkVersion 19
targetSdkVersion 30
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
}
}
dependencies {
implementation 'com.jmedeisis:draglinearlayout:1.1.0'
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.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'
}

Android has a solution to this problem where a new Android project uses AndroidX with some old libraries that use the legacy android support libraries, you are in that case.
The solution is to enable Jetifier in your gradle.properties, like this:
android.enableJetifier=true
You can find more info in these two posts:
Can I use library that used android support with Androidx projects.
What is Jetifier?

Related

Android Studio - R class unknown after Android Studio Update

I needed to perform an update of my android app to update the targetSdkVersion from 29 to 31 (in a first step). In this context, I have updated my Android Studio from 4.0.2 to Android Studio Electric Eel | 2022.1.1. Additionally, I upgraded my Gradle from 6.x to 7.5 (Want to upgrade to 8 at a later stage).
After I performed the update, Android Studio does not find or generate the R class anymore. I get the error "Cannot resolve symbol 'R'" when I import the class with import my.package.R;
Anyhow, I am still able to successfully build my project and run it on an emulator. I also deployed the application on my phone and it works fine. I searched the internet for help and I found that the editor of Android Studio and the build function have different compilers which is why this probably works. However, how can I fix my problem with the editor?
This is what I already did:
I checked my XML for errors (Found and corrected two errors. I only corrected those errors listed in the "Problems" View in the tab "CUrrent file". There are still errors in the "Layout and Qualifiers" tab, but I think those are not critical because they are errors like this: "Touch target size too small - This item's size is 40dp x 40dp. Consider making this touch target 48dp wide and 48dp high or larger.")
I cleaned the project and rebuild it.
I clicked on File -> Sync Project with Gradle Files
I emptied the Cache with File -> Invalidate Caches
Any help to fix this is appreciated. FYI: my gradle looks like this:
apply plugin: 'com.android.application'
def versionMajor = 1
def versionMinor = 0
def versionPatch = 1
android {
compileSdkVersion 31
defaultConfig {
applicationId "my.app.id"
versionCode versionMajor * 10000
+ versionMinor * 100
+ versionPatch
versionName "${versionMajor}.${versionMinor}.${versionPatch}"
minSdkVersion 26
targetSdkVersion 31
versionCode 4
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
vectorDrawables {
useSupportLibrary = true
}
}
buildTypes {
debug {
versionNameSuffix ".debug"
resValue "string", "app_version", "${defaultConfig.versionName}${versionNameSuffix}"
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
resValue "string", "app_version", "${defaultConfig.versionName}"
}
}
namespace 'my.app.id'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
}
buildToolsVersion '30.0.2'
}
repositories {
mavenCentral()
maven { url 'https://maven.google.com' }
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.2'
implementation 'androidx.navigation:navigation-fragment:2.3.1'
implementation 'androidx.navigation:navigation-ui:2.3.1'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
testImplementation 'junit:junit:4.13.1'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation "androidx.room:room-runtime:2.2.5"
annotationProcessor "androidx.room:room-compiler:2.2.5"
implementation 'com.github.bumptech.glide:glide:4.11.0'
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'com.journeyapps:zxing-android-embedded:4.3.0'
}
step 1: clean
step 2: gradle sync
step 3: rebuild the project
If problem still exists try invalidateCache & Restart

How to fix an error while upgrading the targetSdkVersion from version 25 to 27?

As play store doesn't provide me the permission to upload one apk with a targetSdkVersion of 25. So, I upgraded my targetSdkVersion from 25 to 27 and downloaded the all necessary libraries by adding dependencies.
I am provided below the entire build.gradle file code with the changes I made-
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.myApp"
minSdkVersion 17
targetSdkVersion 27
versionCode 2
versionName "1.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
javaMaxHeapSize "2g"
}
repositories {
mavenCentral()
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.android.support:design:27.1.0'
implementation 'com.android.support:recyclerview-v7:27.1.0'
implementation 'com.android.support:support-v4:27.1.0'
implementation 'com.jakewharton:butterknife:8.4.0'
implementation 'de.hdodenhof:circleimageview:2.1.0'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.makeramen:roundedimageview:2.2.1'
implementation 'com.github.whinc:ratingbar:1.1.1'
implementation 'com.iarcuschin:simpleratingbar:0.1.3'
implementation 'com.squareup.retrofit2:retrofit:2.1.0'
implementation 'com.google.code.gson:gson:2.8.0'
implementation 'com.squareup.retrofit2:converter-gson:2.1.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.4.1'
implementation 'in.srain.cube:grid-view-with-header-footer:1.0.12'
implementation 'com.squareup.retrofit2:converter-scalars:2.1.0'
implementation 'pl.bclogic:pulsator4droid:1.0.3'
implementation 'com.intuit.sdp:sdp-android:1.0.4'
implementation 'com.mcxiaoke.volley:library:1.0.19'
implementation 'com.uncopt:android.justified:1.0'
implementation 'com.android.support:multidex:1.0.1'
implementation 'com.github.chrisbanes.photoview:library:1.2.4'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.github.bluejamesbond:textjustify-android:2.1.6'
androidTestImplementation 'junit:junit:4.12'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
}
But after syncing I am getting the following errors-
Information:Gradle tasks [:app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar]
C:\Users\admin.gradle\caches\transforms-1\files-1.1\appcompat-v7-27.1.0.aar\ad0857f7c335bc06a588407b354d6c8b\res\values\values.xml
Error:(251, 5) error: duplicate value for resource 'attr/font' with config ''.
Error:(251, 5) error: resource previously defined here.
K:\my-app\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml
Error:(484) duplicate value for resource 'attr/font' with config ''.
Error:(459) resource previously defined here.
Error:java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:Execution failed for task ':app:mergeDebugResources'.
Error: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Information:BUILD FAILED in 9s
Information:6 errors
Information:0 warnings
Information:See complete output in console
As I can't rollback back to targetSdkVersion 25.Please suggest me any solution to solve this issue and upgrade targetSdkVersion to 27.
a) you need to use the correct build-tools, which are version 27.0.3. while I merely wonder why you updated to API 27 instead of the current API 28; this would use build-tools version 28.0.3.
b) and you have to fix these invalid resources; one duplicate attr/font clashes with com.android.support:appcompat-v7:27.1.0. this comes from any occurrence of <attr name="font" format="string"/> in the project's XML, which has to be removed or renamed.
c) adding the buildscript (most likely twice) into the module-level build.gradle is non-sense. apply plugin: 'com.android.application' also exists twice; this build.gradle is a mess.
Possible duplicate to this question
TLDR Try renaming the library attribute to something else (textFont) ¯\_(ツ)_/¯
Try to add :
classpath 'com.android.tools.build:gradle:3.2.1'
to the project-level build.gradle in dependencies section ( maybe you need to upgrade gradle to 4.6 in gradle-wrapper-properties ) :
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
And increase buildToolsVersion to '28.0.3' in app-level build.gradle.
Then clean project or do './gradlew clean' in terminal in your project directory ( possible with android studio terminal ).

Google material design library error Program type already present: android.support.v4.app.INotificationSideChannel$Stub$Proxy

Whenever i add implemntation 'com.google.android.material:material:1.0.0-alpha1' when i try to build my project Android Studio says:
Program type already present: android.support.v4.app.INotificationSideChannel$Stub$Proxy
Message{kind=ERROR, text=Program type already present: android.support.v4.app.INotificationSideChannel$Stub$Proxy, sources=[Unknown source file], tool name=Optional.of(D8)}
This is my gradle script:
apply plugin: 'com.android.application'
android {
compileSdkVersion 'android-P'
defaultConfig {
applicationId "it.smart.bab3"
minSdkVersion 21
targetSdkVersion 'p'
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'
implementation 'com.google.android.material:material:1.0.0-alpha1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support:design:28.0.0-alpha1'
implementation 'com.android.support:support-v4:28.0.0-alpha1'
}
I'm new ith this type of errors, and i didn't find anithing with this error. Thanks
I've been struggling all day with this issue too. Finally I managed to compile and run the project successfully.
First of all, get rid of this:
implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'
implementation 'com.android.support:design:28.0.0-alpha1'
implementation 'com.android.support:support-v4:28.0.0-alpha1'
Add the following in your gradle.properties file:
android.useAndroidX = true
android.enableJetifier = false
And finally, sync the project and then compile.
If it doesn't work, clean the project and then rebuild.
PS: I can't get targetSdkVersion 'p' to work. My build.gradle file end up as follows:
apply plugin: 'com.android.application'
android {
compileSdkVersion 'android-P'
defaultConfig {
applicationId "com.github.alvarosct02.demo"
minSdkVersion 19
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.google.android.material:material:1.0.0-alpha1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
Hope it works for you too.
I wasted 2 days looking for a solution. Anyone who's still looking for a solution can follow the steps below:
Update your Android Studio to the latest version.
Update your compileSdkVersion and targetSdkVersion to 28.
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.your.appid"
minSdkVersion 19
targetSdkVersion 28
versionCode 50
versionName "1.50"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
setProperty("archivesBaseName", "your-app-$versionName")
resConfigs "en"
}
}
Go to your project structure and change your gradle version to 4.10.
Add this dependency first:
implementation 'com.google.android.material:material:1.0.0'
Now remove all the support library dependencies:
implementation "com.android.support:design:$SUPPORT_LIBRARY_VERSION"
implementation "com.android.support:support-v4:$SUPPORT_LIBRARY_VERSION"
implementation "com.android.support:appcompat-v7:$SUPPORT_LIBRARY_VERSION"
implementation "com.android.support:recyclerview-v7:$SUPPORT_LIBRARY_VERSION"
implementation "com.android.support:cardview-v7:$SUPPORT_LIBRARY_VERSION"
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:multidex:1.0.3'
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
androidTestImplementation('com.android.support.test.espresso:espresso-
core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
exclude group: 'com.google.code.findbugs', module: 'jsr305'
})
Now paste the following into your gradle.properties file:
android.useAndroidX = true
android.enableJetifier = true
In your project level build.gradle file:
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
classpath 'com.google.gms:google-services:4.1.0'
};
For those who are using Butterknife add below lines in your project level build.gradle file:
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
maven { url "https://dl.bintray.com/drummer-aidan/maven/" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}
}
And in your module build.gradle file add below dependencies:
implementation "com.jakewharton:butterknife:9.0.0-SNAPSHOT"
annotationProcessor "com.jakewharton:butterknife-compiler:9.0.0-SNAPSHOT"
Now Goto Build > Rebuild Project then you might be getting a lot of errors.
Now refer this link.
It has the list of all the old (android.support) vs new (androidx.*) dependencies.
Replace all your old imports with the new ones(Use replaceAll feature of android studio [ctrl + shift + R] which will save you some time).
Finally After refactoring all the old libraries with the new ones:Rebuild the project again and hopefully it should work.
Note: You can also use Refactor > Migrate to androidx in android studio but it didn't work for me.
I started getting this error after upgrading the ButterKnife to the version 8.8.1.
So, I run the command gradle -q dependencies to generate a dependency report, after that you should see where D8 is coming from. In my case from the "ButterKnife" library:
+--- com.jakewharton:butterknife:8.8.1
| | \--- com.android.support:support-compat:d8
Also you can see your android dependencies by going to your Android Studio Gradle view (In Android Studio tool bar navigate to "View/Tool Windows/Gradle"), and selecting the target "androidDependencies" under "My-Project-Name/Tasks/android" (Double click to run or Right click and run).
To solve this problem I added this piece of code exclude module: 'support-compat' to my "app/build.gradle" as below:
implementation ('com.jakewharton:butterknife:8.8.1') {
exclude module: 'support-compat'
}
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
Hope it works for someone else :] Cheers!
Android Studio v3.2+ resolves this issue. It also adds a "Migrate to AndroidX" item under the Refactor menu. No work-around or rollback required.
Update Android Studio from the beta channel to use 3.2+ or wait until a stable version is released.
EDIT: Android Studio v3.2 is now in the stable channel. It is important you no longer use the support libraries and migrate to AndroidX libraries because support for the old support libraries has ended.
If you are including a library that has a transitive dependency on the Android support library you also have to use the jetifier feature that is part of the Android Gradle plugin version 3.2.0-alpha14 or higher. You can determine if you have a library that depends on the support library by running your Gradle dependencies task.
From the Android Developer's blog post (https://android-developers.googleblog.com/2018/05/hello-world-androidx.html):
If you depend on a library that references the older Support Library,
Android Studio will update that library to reference androidx instead
via dependency translation. Dependency translation is automatically
applied by the Android Gradle Plugin 3.2.0-alpha14, which rewrites
bytecode and resources of JAR and AAR dependencies (and transitive
dependencies) to reference the new androidx-packaged classes and
artifacts. We will also provide a standalone translation tool as a
JAR.
In your gradle.properties file make sure that you have:
android.enableJetifier=true
android.useAndroidX=true
I had this issue with Leak Canary on a small project and it was solved by upgrading the Android Gradle plugin to the appropriate version. https://github.com/square/leakcanary/issues/1103
Go to app/build.gradle, in dependencies, remove this line:
implementation "com.android.support:appcompat-v7
Try to add
android.enableD8 = false
to gradle.properties file.
If you want to use
com.android.support:support-v4:28.0.0-alpha1,
then you have to use
com.android.support:design:28.0.0-alpha1
instead of
com.google.android.material:material:1.0.0-alpha1.
Use this
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
android {
compileSdkVersion 28
defaultConfig {
applicationId "ir.uncode.newdesign"
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguardrules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0-alpha3'
implementation 'com.android.support:cardview-v7:28.0.0-alpha3'
implementation 'com.android.support:design:28.0.0-alpha3'
implementation 'com.android.support.constraint:constraint-layout:1.1.1'
implementation 'com.android.support:animated-vector-drawable:28.0.0-alpha3'}
repositories {
mavenCentral()
}
and If the problem persists change "import" on class and xml.
like :
import androidx.fragment.app.Fragment;
import android.support.v4.app.Fragment;
or
import androidx.core.app.ActivityCompat;
import android.support.v4.app.ActivityCompat;
or
com.google.android.material.bottomappbar.BottomAppBar
android.support.design.bottomappbar.BottomAppBar
If you are using Android Studio V. 3.2.1 , You can simply go to the tools bar open Refactor -> migrate to AndroidX and Android studio will take care of the rest.
I am using android studio 3.3 version. I wasted my one and a half day looking for this solution. I tried all the answer in this post but nothing helped. Then I find the link which helped me to solve the error.
I removed the below dependency I added,
implemntation 'com.google.android.material:material:1.0.0'
Instead, I used android design support library,
implementation 'com.android.support:design:27.1.1'
try setting android.enableJetifier=true and android.useAndroidX=true
in your gradle.properties file.
If you have 3.1.0 change to 3.2.0:
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
}
You need to move to androidx
Remove all the imports which start with
import android.support.*
Change All imports to import androix.* and corresponding components.

all gms/firebase libaries must use the exact same version. Found versions 15.1.0, 15.0.2, 15.0.1, 15.0.0.

Trying to implement Firebase in my project.
Gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.ghaleh.myapplication"
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:support-media-compat:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso- core:3.0.2'
implementation 'com.google.firebase:firebase-messaging:15.0.2'
}
apply plugin: 'com.google.gms.google-services'
And I'm getting this error:
All gms/firebase libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 15.1.0, 15.0.2, 15.0.1, 15.0.0. Examples include com.google.firebase:firebase-iid:15.1.0 and com.google.android.gms:play-services-measurement-base:15.0.2
According to Google's Maven Repository the latest version of firebase-messaging is 15.0.2 and I'm getting error for firebase-iid:15.1.0
So I cannot upgrade the firebase-messaging to a higher version or implement the firebase-iid:15.1.0 to match the versions.
I've already tried other solutions recommended here: 1, 2, 3 but non of them were useful.
I've also tried this (however it doesn't seem to be a proper solution):
implementation ('com.google.firebase:firebase-messaging:15.0.2') {
exclude group: "com.google.android.gms"
}
and I get this error:
Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForBazaarDebug'.
java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
Thanks in advance.
You need to update google-service plugin to use:
classpath 'com.google.gms:google-services:3.3.0'
to be able to avoid those errors, also upgrade to android studio 3.1
If you're not using Android Studio 3.1 to develop your app, you will need to upgrade in order to get the correct version checking behavior within the IDE.
more information and steps to follow:
Announcing new SDK versioning
Compilation failed to complete:Program type already present: com.google.android.gms.internal.measurement.zzabn
You may need to update
1.Playservice library
2.build tools
3.gradle wrapper
4.AndroidStudio
5.Migration to androidX
6.build tool version
I finally ended up with a proper build after doing this stuff !!!

Firebase Firestore library causes : java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

I am tryng to add Firebase Firestore db to my android application but i get this error:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
here is my build.gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "nfciue.nfcsmartanimalpassport"
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
repositories {
flatDir {
dirs 'libs'
}
maven {
credentials {
username "sdkuser"
password "taplinx"
}
url "http://maven.taplinx.nxp.com/nexus/content/repositories/taplinx/"
}
}
}
dependencies {
//noinspection GradleCompatible
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
compile 'com.google.firebase:firebase-firestore:11.8.0'
compile('taplinx-android:nxpnfcandroidlib:1.3#aar') {
transitive = true
}
apply plugin: 'com.google.gms.google-services'
}
also "compile 'com.google.firebase:firebase-firestore:11.8.0'" causes warning that says:
All gms/firebase libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 11.8.0, 10.0.1. Examples include com.google.android.gms:play-services-basement:11.8.0 and com.google.android.gms:play-services-analytics:10.0.1 less... (Ctrl+F1)
There are some combinations of libraries, or tools and libraries, that are incompatible, or can lead to bugs. One such incompatibility is compiling with a version of the Android support libraries that is not the latest version (or in particular, a version lower than your targetSdkVersion.)
As a beginner, these errors and warnings are complicated for me. Any help ?
Add this to your app level build gradle:
implementation 'com.google.android.gms:play-services-analytics:11.8.0'
This will clear alway the "All gms/firebase libraries must use the exact same version specification".
As for the dex problem I've encountered the problem many times before and it was always fixed with using the latest version of the compileSdkVersion and of the libraries I was using.

Categories