I'm experiencing a build issue when adding a firebase dependency to a android library.
My setup is as follows
/settings.gradle
include ':module-lib'
include ':module-app'
/build.gradle
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.google.gms:google-services:4.0.0'
}
}
/module-lib/build.gradle
apply plugin: 'com.android.library'
android {
...
}
dependencies{
api "com.google.firebase:firebase-config:16.0.0"
}
/module-app/build.gradle
apply plugin: 'com.android.application'
android {
...
}
dependencies {
implementation project(':module-lib')
}
apply plugin: 'com.google.gms.google-services'
Short log:
$ ./gradlew clean build
Starting a Gradle Daemon, 1 busy and 2 stopped Daemons could not be reused, use --status for details
Parallel execution is an incubating feature.
> Configure project :module-app
Detected alwaysUpdateBuildId set to false while obfuscation is enabled. This may result in obfuscated stack traces in Crashlytics.
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
> Task :module-lib:compileDebugAidl FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Failed to notify dependency resolution listener.
> Cannot invoke method get() on null object
> Cannot invoke method get() on null object
* 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.
* Get more help at https://help.gradle.org
BUILD FAILED in 18s
13 actionable tasks: 8 executed, 5 from cache
You can find the full stacktrace of the original error in this pastebin
The funny thing is that module-lib
only contains a placeholder, empty and useless class. If I removed the firebase dependency from module-lib
and move it to module-app
, the build works fine.
I'm not using Android Studio, so this is a purely Gradle and/or plugin and/or dependencies issue.
Also note that
./gradlew clean // Always succeds
./gradlew build // Sometimes works with above error
./gradlew clean build // Always fails with above error
This also happens with any firebase-*
dependency included in a module that applies the library plugin com.android.library
.
More environment info
$ ./gradlew -version
------------------------------------------------------------
Gradle 4.7
------------------------------------------------------------
Build time: 2018-04-18 09:09:12 UTC
Revision: b9a962bf70638332300e7f810689cb2febbd4a6c
Groovy: 2.4.12
Ant: Apache Ant(TM) version 1.9.9 compiled on February 2 2017
JVM: 1.8.0_162 (Oracle Corporation 25.162-b12)
OS: Mac OS X 10.13.4 x86_64
Any clues or tips are more than welcome :)
Thanks!
Upgrading the google-services
plugin to version 4.0.1
fixed the issue.
From the Firebase sdk changelog page: https://firebase.google.com/support/release-notes/android
In other words, change this:
classpath 'com.google.gms:google-services:4.0.0'
to this:
classpath 'com.google.gms:google-services:4.0.1'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With