Unable to merge dex when a module is imported - android

I know there are many questions on this, but I tried the solutions of most of them and neither of them worked.
I have an app in which I have imported a module. When I try to run the app, I am getting Unable to merge dex exception.
build.gradle (app module)
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.meditab.imspatient"
minSdkVersion 21
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'])
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'
implementation 'com.android.support.constraint:constraint-layout:1.0.2' // Constraint layout
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" // Kotlin
// Support libraries
implementation "com.android.support:appcompat-v7:$appcompat_version"
implementation "com.android.support:support-v4:$appcompat_version"
compile project(path: ':commonutils')
}
build.gradel (imported module)
apply plugin: 'com.android.library'
android {
compileSdkVersion 27
buildToolsVersion '27.0.2'
defaultConfig {
minSdkVersion 21
targetSdkVersion 27
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'org.jetbrains:annotations-java5:15.0'
compile 'com.jakewharton:butterknife:8.8.1'
// Support libraries
compile "com.android.support:appcompat-v7:$appcompat_version"
compile "com.android.support:design:$appcompat_version"
// Rx related libraries
compile 'io.reactivex:rxjava:1.1.1'
compile 'io.reactivex:rxandroid:1.1.0'
//compile 'com.netflix.rxjava:rxjava-core:0.+'
// Networking related libraries
compile 'com.squareup.okhttp3:logging-interceptor:3.8.1'
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:converter-jackson:2.0.2'
compile 'com.squareup.retrofit2:adapter-rxjava:2.0.2'
compile 'com.fasterxml.jackson.core:jackson-databind:2.7.2'
compile 'com.google.firebase:firebase-core:11.8.0'
compile 'com.google.firebase:firebase-messaging:11.8.0'
compile 'com.google.android.gms:play-services-base:11.8.0'
compile 'com.google.android.gms:play-services-location:11.8.0'
compile 'com.estimote:sdk:0.10.+#aar'
}
build.gradle (project level)
buildscript {
ext.kotlin_version = '1.2.21'
ext.appcompat_version = '27.0.2'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// Needed for the common utils module
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I have tried deleting the .gradle folder, cleaning the project and rebuilding it. Nothing works. I also tried using implementation instead of compile in the build.gradle of the imported module.
Any help will be appreciated.
Thanks in advance.

It seems that 2 libraries you're declaring a dependency on are causing duplicate entries.
The problem is that you can't have the exact same class or annotation declared by 2 different libraries. If they were different versions of the same library probably the one with the highest version would be picked, but if they are completely different libraries, there is no way to tell which implementation should be included in the dex file.
The first one is:
'com.netflix.rxjava:rxjava-core:0.+'
Why would you use this? You have already defined a dependency on RxJava ('io.reactivex:rxjava:1.1.1') and they probably have many classes in common, the first that comes to my mind and that I checked is rx.Observable. The last update for that repo is Novermber 2014, more than 3 years ago. Besides conflicts, this fact alone should be a very good reason not to use it.
The second problem is:
'org.jetbrains:annotations-java5:15.0'
I imagine that you're importing this in order to get org.jetbrains.annotations.Nullable, this is already available in your project because Kotlin stdlib has a dependncy on org.jetbrains:annotations that also declares it. Hence the conflict.
Remove these 2 dependencies, you most likely don't actually need them anyway, and the project compiles.

I'm not 100 percent sure but I think you need to enable multidex in your app. Check this link : Enable Multidex
Just trying to help.

In my previous project which has multiple modules If I enable Proguard I was getting the same error.
That error frustrating and In my case I solved problem after inspecting
the project dependency graph(Using gradle to find dependency tree may help you while finding dependencies)
Play service's different version was causing in my case

Related

Failing on build with androidX error but I am not using androidX in project

I am trying to build but it gives me errors. I did research and tried following solutions but cant fix.
https://github.com/objectbox/objectbox-java/issues/386
Unable to merge dex
Error - Android resource linking failed (AAPT2 27.0.3 Daemon #0)
Error: Program type already present: androidx.versionedparcelable.ParcelImpl
Thats the error
Error: Program type already present: androidx.versionedparcelable.NonParcelField
Thats the screen
Thats my code
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.30"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
and this one
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.adultgaming.fantasygameapp"
minSdkVersion 17
targetSdkVersion 27
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:multidex:1.0.3'
//Kotlin
implementation "androidx.core:core-ktx:1.0.1"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.30"
//Glide
implementation 'com.github.bumptech.glide:glide:4.9.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
//Eventbus
implementation 'org.greenrobot:eventbus:3.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'
}
Please let me know if I missed something. And if want to devote let me know why.
First, check inside your gradle.properties, if you have
android.enableJetifier=true
android.useAndroidX=true
Then you do have androidx enabled.
Also, and this may be obvious, but clean your Gradle build with Build -> Clean Project
UPDATE WITH ANSWER
What is happening is one of your other libraries is using androidx, GLIDE FOR SURE, and maybe others.
You have two options...
Easy: Upgrade to androidx... Like why not? Totally worth it.
Hard: Downgrade your dependencies versions to pre androidX versions.

Build Failed: Program Type Already Present

I have searched online about this error and the issue always seems to end up being some sort of dependency conflict. I think I am supposed to add exclude after certain dependencies, but I am unsure which one(s). It's also unclear based on the error which dependency I should actually exclude; all I know is that the group is probably com.android.support...
Here's what I've tried:
Adding multiDexEnabled true to my defaultConfig block in build.gradle.
Cleaning the project in Android Studio.
Manually deleting (from the file system) the entire .gradle directory.
I've made sure compileSdkVersion and targetSdkVersion are the same.
I've made sure all my Android dependencies use the same version (namely 26.1.0).
Despite all this, I still get this error when I build:
Program type already present: android.support.compat.R$bool
and from the Java compiler:
Caused by: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
F:\ExampleProject\app\build\intermediates\transforms\dexBuilder\debug\115,
F:\ExampleProject\app\build\intermediates\transforms\externalLibsDexMerger\debug\0
Here is my module's build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.myapp.exampleproject"
minSdkVersion 17
targetSdkVersion 26
versionCode 1
versionName "1.2"
}
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:26.1.0'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.android.support:support-compat:26.1.0'
implementation 'com.android.volley:volley:1.1.0'
implementation 'com.github.bumptech.glide:glide:4.1.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.1.0'
}
and lastly, my project's build.gradle file:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Any help in rectifying this would be greatly appreciated.
This is a problem with Glide 4.1.0. Use the version 4.1.1 instead which fix the bug by remove the R*.class file from their dependencies. (source)
This is probably because of Glide library. Try to exclude the support library from it with:
// add support-fragment removed from Glide.
implementation "com.android.support:support-fragment:26.1.0"
implementation ('com.github.bumptech.glide:glide:4.1.0') {
exclude group: 'com.android.support'
exclude module: 'support-fragment'
exclude module: 'appcompat-v7'
}
You can see the support library inside Glide at Glide build.gradle
Solution:
implementation ('com.github.bumptech.glide:glide:4.1.0') {
exclude group: 'com.android.support'
exclude module: 'support-fragment'
exclude module: 'appcompat-v7'
}

Android Studio: Execution failed for task: unable to merge dex

I just add a module to my android project. Android Studio builds the project correctly, but when I attempt to launch the app, I getting this error.
Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'. > com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
My project gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.2.21'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.apollographql.apollo:apollo-gradle-plugin:0.4.4'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
My module gradle:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'com.apollographql.android'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.yamblet.smartliving"
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'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':openpayandroid')
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:design:26.1.0'
implementation 'com.jakewharton:butterknife:8.8.1'
implementation 'com.airbnb.android:lottie:2.0.0'
implementation 'org.apache.commons:commons-lang3:3.4'
implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.apollographql.apollo:apollo-runtime:0.4.4'
implementation "com.apollographql.apollo:apollo-android-support:0.4.4"
implementation 'com.apollographql.apollo:apollo-http-cache:0.4.4'
implementation 'com.github.bumptech.glide:glide:3.7.0'
implementation 'jp.wasabeef:glide-transformations:2.0.1'
implementation 'com.master.android:permissionhelper:1.1'
implementation 'com.iamhabib:easy-preference:1.0.1'
implementation 'com.android.support:recyclerview-v7:26.1.0'
implementation 'com.github.jkwiecien:EasyImage:2.0.2'
//RETROFIT
implementation 'com.squareup.retrofit2:retrofit:2.1.0'
//JSON PARSING
implementation 'com.google.code.gson:gson:2.6.1'
implementation 'com.squareup.retrofit2:converter-gson:2.1.0'
implementation 'com.android.support:cardview-v7:26.1.0'
implementation 'com.master.android:permissionhelper:1.1'
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'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
}
repositories {
maven { url "https://jitpack.io" }
mavenCentral()
}
apply plugin: 'kotlin-android-extensions'
Module gradle that I added
apply plugin: 'com.android.library'
android {
compileSdkVersion 19
buildToolsVersion "26.0.2"
defaultConfig {
minSdkVersion 7
targetSdkVersion 19
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:19.+'
compile files('libs/devicecollector-sdk-2.5.jar')
compile files('libs/google-http-client-1.17.0-rc.jar')
compile files('libs/google-http-client-android-1.17.0-rc.jar')
compile files('libs/google-http-client-jackson2-1.17.0-rc.jar')
compile files('libs/jackson-core-2.1.3.jar')
compile files('libs/jackson-core-asl-1.9.11.jar')
compile files('libs/jsr305-1.3.9.jar')
compile files('libs/junit-4.10.jar')
}
I clean and rebuild the project but, the error persists in the build process. Also I add multiDexEnabled true but didnt work. Thanks for your help.
I executed this gradle, and it works only problem I can see here is implementation project(':openpayandroid'), i didn't included it as its your private library, but on my understanding openpayandroid is also including some same dependencies which is causing the problem, so solution can be to exclude that group from it, eg implementation project(':openpayandroid')
{
exclude group 'the dex error causing lib group'
}
if above does'nt work try this
in your project build.gradle try use same version of all the groups e.g.
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex')) {
details.useVersion "26.1.0" // your version
}
I think this might help but if this doesn't work try to check which file is responsible for this dex error and edit your question
One more thing you have include permission helper twice, remove (but it might not be the problem )
Make sure you have multiDexEnabled true ie. multidex enabled in your app gradle under android section
In build.gradle in default config use
multiDexEnabled true
and add dependency like compile 'com.android.support:multidex:1.0.3'
and extend your application file with MultidexApplication and rebuild your project. This will help you.
If you update the dependencies recently try this answer
Just clean the project & re-build the project
Build -> Clean project
Build -> Rebuild project

duplicate entry error after adding google services

I wanted to add firebase to one of my app. I integrated firebase according to firebase offical documents. but when I tried to "run" app. it gives me this warning
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/internal/zzc.class
I removed all the firebase coding & removed it from gradle file. but error still exist untill I remove this line
apply plugin: 'com.google.gms.google-services'
but unfortunately I need google services to work with firebase. here is my app gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '23.0.3'
defaultConfig {
applicationId ""
minSdkVersion 19
targetSdkVersion 22
versionCode 15
versionName "2.01"
multiDexEnabled true
}
dexOptions {
preDexLibraries = false
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile files('libs/main.jar')
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:cardview-v7:23.0.+'
compile 'com.android.support:recyclerview-v7:23.0.+'
compile 'com.squareup.picasso:picasso:2.5.0'
compile 'com.commit451:NativeStackBlur:1.0.1'
compile 'com.google.firebase:firebase-analytics:9.0.0'
compile 'com.github.bumptech.glide:glide:3.6.1'
compile 'com.facebook.android:audience-network-sdk:4.11.0'
}
apply plugin: 'com.google.gms.google-services'
here is my project gradle file
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
The problem was with Facebook Audience network. once I excluded google services it worked fine. If anyone having same problem change your audience network dependency like this
compile ('com.facebook.android:audience-network-sdk:4.11.0'){
exclude group: 'com.google.android.gms'
}
Add these dependencies:
compile 'com.google.android.gms:play-services-location:11.0.4'
compile 'com.google.android.gms:play-services-maps:11.0.4'
compile 'com.google.android.gms:play-services-gcm:11.0.4'
compile 'com.google.android.gms:play-services-places:11.0.4'
Add
android{
....
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
}
to your app's gradle file.
Add Firebase related dependencies
And Firebase related dependencies under dependencies in the same build.gradle file.
dependencies {
compile 'com.google.firebase:firebase-core:9.2.0' // this line must be included to integrate with Firebase
compile 'com.google.firebase:firebase-messaging:9.2.0' // this line must be included to use FCM
}
Update services using com.google.android.gms:play-services
If you add Firebase into an existing project which uses any function of gms:play-services, such as gps location,
you have to update their versions, too. Upon writing this tutorial, 9.2.0 works well. If you get compilation problems, you need to check find out the correct version number.
compile 'com.google.android.gms:play-services-location:9.2.0'
compile 'com.google.android.gms:play-services-places:9.2.0'
Source:
https://www.codementor.io/flame3/send-push-notifications-to-android-with-firebase-du10860kb

Failed to resolve: com.firebase:firebase-client-android:2.3.1

I am working on the Sample in the below blog
https://www.firebase.com/blog/2015-10-01-firebase-android-app-engine-tutorial.html
The projects fails to compile after adding the dependency
compile 'com.firebase:firebase-client-android:2.3.1'
Other dependencies compile without any issue.
'com.android.support:appcompat-v7:23.0.1'
'compile 'com.android.support:design:23.0.1'
Where am I going wrong ?
here is my module build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.tri.todoapp"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
// testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
compile 'com.firebase:firebase-client-android:2.4.0'
}
Top-level gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
The project fails to compile because version 2.3 doesn't exists. You should use 2.3.1:
compile 'com.firebase:firebase-client-android:2.3.1'
or the newest 2.4.0:
compile 'com.firebase:firebase-client-android:2.4.0'
You can find more information here:
https://www.firebase.com/docs/android/quickstart.html
We are talking about Google api versions without mentioning Google Repository version.
The actual problem here is that your Google Repository doesn't "know" about the firebase version you all were trying to use.
I got same error while following the official firebase documentation
My app-level build.gradle file looked like this:
apply plugin: 'com.android.application'
android {
// ...
}
dependencies {
// ...
compile 'com.google.firebase:firebase-core:10.2.1'
compile 'com.google.firebase:firebase-messaging:10.2.1'
}
apply plugin: 'com.google.gms.google-services'
My Google Repository version was 44
You can check yours in
SDK Manager>Android SDK> SDK Tools (tab)
Latest version is 46 (at the time of writing this)
I updated to latest Google Repository version and the problem was solved!
You can update by checking "Google Repository" under SDK Tools tab and click "Apply" to update Google Repository to latest version
If you do not wish to update your Google Repository version, you can still resolve the issue by lowering your firebase api version slighlty.
For my case, changing app-level build.gradle file to the following also fixes my problem:
apply plugin: 'com.android.application'
android {
// ...
}
dependencies {
// ...
compile 'com.google.firebase:firebase-core:10.2.0'
compile 'com.google.firebase:firebase-messaging:10.2.0'
}
apply plugin: 'com.google.gms.google-services'
firebase version has been lowered to version 10.2.0 from 10.2.1
This works because 10.2.0 is known to Google repository ver 44.
I hope this answer will help many in future.
There are two modules you need to add firebase to:
The android module: You should use the "Add Firebase" checkbox that appears in project structure that will add 2.3.1 to the android app.
The backend module requires 2.4 to run in app engine and those steps require you to add the dependency manually.
In that case, be sure you are adding the jvm client -- not the "android" client for app engine.
compile 'com.firebase:firebase-client-android:2.4.0'
It happens because this version
compile 'com.firebase:firebase-client-android:2.3'
doesn't exist.
You can use one of these:
compile 'com.firebase:firebase-client-android:2.4.0'
compile 'com.firebase:firebase-client-android:2.3.1'
compile 'com.firebase:firebase-client-android:2.3.0'
Pay attention.
compile 'com.firebase:firebase-client-android:2.3.0'
is different from
compile 'com.firebase:firebase-client-android:2.3'
You can find the full list in maven:
using
compile 'com.firebase:firebase-client-android:+'
worked for me.
I had the exact same problem today, but with version 2.4.1. I could however not open the link l jcenter.bintray.com/com/firebase/firebase-client-android/2.4.1/ as mentioned by Mattia Maestrini.
Solution for me: Deactivate my VPN, and then it worked.
it looks like it was a dex limit error. Adding the Firebase SDK must have put me over the limit, to fix this i had to add multiDexEnabled true in the defaultConfig section of my app:build.gradle file as well as compile 'com.android.support:multidex:1.0.0' in the dependencies
Here is my gradle
gradle for project
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
gradle module app
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.tranetech.openspace.firebasedemo"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.firebase:firebase-client-android:2.5.2+'
compile 'com.firebaseui:firebase-ui:0.3.1'
compile 'com.android.support:multidex:1.0.0'
}
I not sure you still working with that project or not, but I also faced the same problem with you, my solution is
In your build.gradle (outside the app folder one), add
buildscript {
repositories {
jcenter()
}
dependencies {
////
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
and in your module build.gradle, add
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.+'
compile 'com.android.support:design:23.+'
compile 'com.google.firebase:firebase-core:9.2.1'
compile 'com.google.firebase:firebase-database:9.2.1'
compile 'com.firebase:firebase-client-android:2.4.0'
}
apply plugin:
'com.google.gms.google-services'// <- this code
And the last, don't forget to download google-services.json put in your app folder, the path should look like \yourapplication\app, you also can refer to this link for download google-services.json file. Download a configuration file
compile is deprecated. You should use:
implementation 'com.firebase:firebase-client-android:2.5.2'

Categories

Resources