Firebase libraries with conflicting library versions fail to run my app - android

So i'm using the following firebase library version in my app:
Project's build.gradle:
firebase_version = '15.0.0'
And the following library dependencies:
App's build.gradle:
implementation "com.google.firebase:firebase-firestore:$firebase_version"
It looks like these versions were released on the 10th of April, however when compiling my app with the updated libraries, it fails to run with the following error:
error: cannot access zzbgl
class file for com.google.android.gms.internal.zzbgl not found
When checking all my library versions, my build.gradle has the following error:
not sure if anyone has experienced this by any chance since the latest updates? Before updating from 12.0.1, everything was working.
Thanks

Simply override (add to your gradle file) the conflicting library, updating the version to match the ones you already have in your gradle file. Somewhere in your dependencies someone is using an older version of this library and it's crashing with your version:
implementation "com.google.android.gms:play-services-auth:$firebase_version"

Related

Android dependency has different version for the compile and runtime classpath

I am using a lot of Firebase related libraries in my project. Upon syncing, I am facing the following error.
Android dependency 'com.google.firebase:firebase-iid' has different
version for the compile (17.0.3) and runtime (17.1.1) classpath. You
should manually set the same version via DependencyResolution
The thing is that I have not even declared firebase-iid in my dependencies and this is coming as a transitive dependency from other firebase libraries.
Upon running the dependency chart, I am able to find the following things.
Version 17.0.3 is coming from com.google.android.gms:play-services-measurement-api:16.4.0
Whereas 17.1.1 is coming from com.google.firebase:firebase-messaging:17.5.0
Ideally it should resolve it internally and the higher version should be automatically picked. But this is not happening.
Any idea why this is happening and how to resolve this issue?
There is not updated gradle for com.google.android.gms:play-services-measurement-api:
The latest release is on March 2019, version : 16.4.0 .
So, your implementation is not correct for this measurement-api .
Use :
com.google.android.gms:play-services-measurement-api:16.4.0
com.google.firebase:firebase-messaging:17.5.0
refer this link : https://mvnrepository.com/artifact/com.google.android.gms/play-services-measurement-api/16.4.0
https://mvnrepository.com/artifact/com.google.firebase/firebase-messaging
Yes you are right, gradle should automatically resolve to a single version of a library, but as I experienced sometimes, it does, sometimes, it does not. But when It does not resolve to a single version of same library, we can force it to use a single specific version like explained below.
configurations.all {
resolutionStrategy {
force "com.google.android.gms:play-services-measurement-api:17.1.1"
force "com.google.firebase:firebase-messaging:17.5.0"
}
}
dependencies {
// ... all dependencies here...
}
Try using above code forcing gradle to use a single version. Might help in your case.

How to migrate from Kotlin 1.2 to 1.3 with the kotlin-dsl Gradle plugin?

I am currently using the kotlin-dsl Gradle plugin 0.18.2, Kotlin 1.2.51 and Gradle 4.10.2 in my Android project (take a look at the temporary project-setup branch).
I like to migrate to Kotlin 1.3. However, I have difficulties in finding out which combination of version works. I raised the dependencies to their latest version:
// in build.gradle.kts:
id("org.gradle.kotlin.kotlin-dsl") version "1.0.4"
...
// in build.gradle:
org.jetbrains.kotlin:kotlin-stdlib:1.3.10
As soon as I run a Gradle task it fails with the following error:
WARNING: Unsupported Kotlin plugin version.
The embedded-kotlin and kotlin-dsl plugins rely on features of Kotlin 1.2.61 that might work differently than in the requested version 1.3.10.
Is there a migration guide besides what is written in the release notes of the kotlin-dsl Gradle plugin?
Related
kotlin-dsl issue #1269: Build failed with NoSuchMethodError: KotlinPluginWrapperKt.getKotlinPluginVersion
The source of the migration problems was a misconfiguration of the buildSrc folder. I was treating it as a module in the settings.gradle file:
include ':app', ':buildSrc', ':database', ':network'
Instead it should be treated as an included build as stated in the Gradle documentation.
The solution given by Paul Merlin, #eskatos was to simply remove the buildSrc folder there:
include ':app', ':database', ':network'

error: package com.google.android.gms.ads.identifier does not exist when deploying to target

I'm a bit new to the Gradle build system. My app already had some working integrations with Google Play Services, including the Ads library. I'm trying to add the Android Nearby service to my build.gradle, but the import for the ads library no longer works specifically after I added in the Nearby library.
In my build.gradle:
dependency {
implementation "com.google.android.gms:play-services-nearby:$rootProject.ext.playServicesLibraryVersion"
}
playServicesLibraryVersion is 15.0.1, which is the latest. The project builds successfully, but the errors arise specifically when I'm deploying to target. My target device is running Android P and I'm using Android Studio 3.1.2.
If I add implementation "com.google.android.gms:play-services-ads:$rootProject.ext.playServicesLibraryVersion" I get a Multiple Dex error.
Any ideas?
Update: issue was resolved when I did a clean build, invalidated cache, and used api instead of implementation in the build.gradle. I added both libraries to my dependencies.

Can I Include an android library that uses an older gradle plugin in a newer project?

I have a newer android project that's using the 2.3 gradle plugin in Android Studio. I am trying to include an older android library that uses the 2.0.+ gradle plugin.
If I just compile the library by itself, it compiles successfully. When I include ':library' and put this library in the main project's dependencies{ compile project(':library') }, I get the following error on Gradle Sync:
Error:(50, 0) Could not get unknown property 'assembleDebug' for object of type com.android.build.gradle.LibraryExtension.
The library's build.gradle file has an assembleDebug block, and from this issue: https://code.google.com/p/android/issues/detail?id=219732#c21, it seems to be related to some change in the 2.2 gradle plugin.
I'm not the author of the library, so I don't to change anything in the library itself, just use it. Is it possible to include this older library in the newer project without having to modify the library's build.gradle file to work with the newer gradle version?

Android gradle JAR dependency ends up declared as native

In my Android projects build.gradle file I have:
dependencies {
compile 'org.apache.directory.studio:org.apache.commons.io:2.4'
compile 'org.apache.commons:commons-collections4:4.0'
}
When I run aapt dump badging I see:
native-code: 'commons-io-2.4.jar'
Clearly commons-io is not native code but the Android Gradle plugin thinks it is. How can I tell the Android Gradle plugin this library does not contain native code? Also curious how did it decide what architecture this library is? It seems to have picked some variety of arm since the APK won't install on a intel-based Android emulator, it gives the error: INSTALL_FAILED_CPU_ABI_INCOMPATIBLE.
You may be using the incorrect Commons IO library. Try:
http://mvnrepository.com/artifact/commons-io/commons-io/2.4
The version you're using seems to be specific to Apache Directory Studio 2.4 which seems to be a desktop app.
I once had troubles introducing a dependency on commons-io:2.4 into my build code. The problem is that Gradle itself comes with a version of commons-io. In my case it could be fixed with this:
sourceSets {
main {
compileClasspath = configurations.compile.minus files("$gradle.gradleHomeDir/lib/commons-io-1.4.jar")
}
}
I took this snippet from My Gradle project depends on commons-io 2.4, but Gradle puts $GRADLE_HOME/commons-io-1.4.jar into the classpath, causing failures
But be aware that it is not recommended to use different versions of libraries to come with Gradle.
You can find more information about this here: https://discuss.gradle.org/t/unable-to-use-commons-io-2-4-because-gradle-forces-the-loading-of-commons-io-1-4/8021
This might aswell be completely unrelated :)

Categories

Resources