Closed mateuszkwiecinski closed 3 years ago
Any suggestions for this? Happening to me too exactly as described. I tried rebuild and clear cache&restart as well. No good.
With Android Studio 3.3 Stable, I have also encountered this issue.
Same problem here with Android Studio 3.3 Stable. Does Anyone know how to solve the issue?
I downgrade to gradle 3.2.1 and it works perfectly.
Only downgrade to version 4.0.2 of 'com.google.gms:google-services' works for me.
4.2.0 throws java.lang.NullPointerException
during build
4.1.0 version does not create /build/generated/res/google-services/{build_type}/values/values.xml file
and application throws
java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process. Make sure to call FirebaseApp.initializeApp(Context) first.
Facing this issue as well. Android studio 3.3 and GPS 4.2.0.
@mdawid described it best. Even with 4.1.0 I get the FirebaseApp not initialized error.
Same issue here. Android studio 3.3 and GPS 4.2.0.
Thanks for the reports all. As of now, we have been unable to reproduce this NPE internally. Would one of the folks on this issue be so kind as to provide a minimally reproducing project they can point us to in order to replicate?
For me it always happens when trying to add the google.gms.service plugin inside an android library plugin. It automatically throws the NPE.
@zhiqiao https://github.com/VeegaP/GooglePlayServicesNPE This causes NPE, although I haven't reproduced the Firebase not initialized issue on a small project
Hmm, is there any particular reason to apply this plugin to a library? That is: is there an edge case I'm missing? Or would it be correct to say that the problem here is that the error message isn't very nice?
@davidmotson I do not understand why this worked until AS 3.2.1, gradle 4.6 and the same plugin version 4.2.0. I don't get why this is throwing an error on a library and works well on an application. There is a known issue/best practices on where do we use this plugin?
The error was introduced by an unrelated code change to support instant apps. It seems broken for non-instant app library modules.
But I want to make sure that I fix the root error here. Which I'm reading right now as a bad error message. When applied to a library the plugin should do... nothing, is my understanding.
So my question is: Is there something that you expect the plugin to do when applied to a library? What functionality should it have in that case? Or should it just be nothing, or an error message that tells you to remove it from that module.
@davidmotson Wouldn't it make sense to be able to use it with the firebase SDK in a library module, such as the module for the data layer of an application?
Is that something that works now/worked with older versions of the google-services plugin? It seems you would still have to apply it to the top level android app, right?
Or if you kept all the firebase stuff locked away in a library you could apply it to the library and not the top level app?
That's precisely what I did, lock away all data-related stuff on a library module, make dependencies from it to my domain module, and inject dependencies into it in a top level android app module using dagger.
for me, same problem of these gentlemen: Android studio 3.3 com.android.tools.build:gradle:3.3.0 com.google.gms:google-services:4.2.0 If I change only the gradle plugin to 3.2.1, all errors go away
@VeegaP: And you didn't have to apply the google-services plugin on the top level android app, only on that library module? Or is it applied to both? because if its both, I think the library level application is extraneous. If that's not the case (you apply the plugin only to the library), would you be ok with me having you test a fix for this?
@PhantomLord72: That makes sense, the NPE is in a part of the code that uses a new API conditionally on it existing, and it only starts to exist in 3.3.0
Trying to build multi module project on Android Studio 3.3
top level project build.gradle
contains
classpath 'com.google.gms:google-services:4.1.0'
classpath 'com.android.tools.build:gradle:3.2.0'
base module build.gradle
contains
apply plugin: 'com.google.gms.google-services'
at the end of file (as mentioned here)
Updating classpath 'com.android.tools.build:gradle:3.2.0'
to 3.3.0 causes the app to crash as values file isn't generated.
Updating classpath 'com.google.gms:google-services:4.1.0'
to 4.2.0 causes NullPointerException at build without any description.
@davidmotson For myself, I didn't have to apply it to the top level application project, when the plugin was applied to the library project.
I'm also getting this error. My project has library modules and an app module. One of these library modules depends on Firebase and a library module too. I apply the plugin on the app module, but I get unresolved dependencies even though I set up the repositories correctly (google()
first in allprojects { … }
). I tried to apply the plugin on the library too, but now get this error.
Frankly speaking, the new version scheme that started in version 15.0.0 has been a horror story so far, and I'd have thought it would improve after these months, but here I am…
i just add this and its working
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:animated-vector-drawable:28.0.0'
implementation 'com.android.support:support-media-compat:28.0.0'
my dependencies (project)
classpath 'com.android.tools.build:gradle:3.3.1'
classpath 'com.google.gms:google-services:4.2.0' // google-services plugin
Okay so I am now able to use Google Services 4.2.0.
So in my experience I have two modules. An API module that implements firebase libraries. As well as a App module that also implements firebase libraries.
My App module implements the Api module. In my Api Gradle module I removed the google services plugin as well as the google-services.json file.
I only included the google services plugin and the google-services.json file in the app module.
In my case it now works.
Api Gradle
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
testOptions {
unitTests {
includeAndroidResources = true
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "androidx.appcompat:appcompat:$appcompat_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation "org.kodein.di:kodein-di-generic-jvm:${kodein_version}"
implementation "org.kodein.di:kodein-di-framework-android-x:${kodein_version}"
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_ext_version"
implementation "com.google.android.material:material:$material_version"
//Firebase
implementation "com.google.firebase:firebase-core:$fire_core_version"
implementation "com.google.firebase:firebase-auth:$fire_auth_version"
implementation "com.google.firebase:firebase-firestore:$fire_store_version"
implementation "com.jakewharton.timber:timber:$timber_version"
implementation "com.github.ajalt:timberkt:$timberkt_version"
// Unit Testing
testImplementation "junit:junit:$junit_version"
testImplementation "org.mockito:mockito-inline:2.23.0"
testImplementation "org.robolectric:robolectric:$robolectric_version"
testImplementation "androidx.test:core:$test_core_version"
testImplementation "androidx.test.ext:junit:$test_ext_version"
testImplementation "androidx.test:runner:$test_runner_version"
testImplementation "androidx.test:rules:$test_rules_version"
}
App Gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
android {
signingConfigs {
debug {
keyAlias 'androiddebugkey'
keyPassword 'android'
storeFile file('keystore/debug.keystore')
storePassword 'android'
}
}
compileSdkVersion 28
defaultConfig {
applicationId "mobi.lotustechnologies.gratifee"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
debug {
applicationIdSuffix '.staging'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
testOptions {
unitTests {
includeAndroidResources = true
}
}
useLibrary 'android.test.runner'
useLibrary 'android.test.base'
useLibrary 'android.test.mock'
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation project(':api')
//Kotlin
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
//Kodein
implementation "org.kodein.di:kodein-di-generic-jvm:${kodein_version}"
implementation "org.kodein.di:kodein-di-framework-android-x:${kodein_version}"
//Android
implementation "androidx.appcompat:appcompat:$appcompat_version"
implementation "androidx.core:core-ktx:$ktx_version"
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_ext_version"
//Firebase
implementation "com.google.firebase:firebase-core:$fire_core_version"
implementation "com.google.firebase:firebase-auth:$fire_auth_version"
implementation "com.google.firebase:firebase-firestore:$fire_store_version"
implementation "com.google.firebase:firebase-storage:$fire_storage_version"
//UI
implementation "androidx.constraintlayout:constraintlayout:$constraint_version"
implementation "com.google.android.material:material:$material_version"
implementation "androidx.recyclerview:recyclerview:$recyclerview_version"
implementation "androidx.cardview:cardview:$cardview_version"
implementation "com.mikepenz:materialdrawer:$material_drawer_version"
//Glide
implementation "com.github.bumptech.glide:glide:$glide_version"
kapt "com.github.bumptech.glide:compiler:$glide_version"
//FastAdapter
implementation "com.mikepenz:fastadapter:$fastadapter_version"
implementation "com.mikepenz:fastadapter-commons:$fastadapter_version"
implementation "com.mikepenz:fastadapter-extensions-expandable:$fastadapter_version"
implementation "com.mikepenz:fastadapter-extensions:$fastadapter_version"
// Unit Testing
testImplementation "junit:junit:$junit_version"
testImplementation "org.mockito:mockito-core:2.23.0"
testImplementation "org.robolectric:robolectric:$robolectric_version"
testImplementation "androidx.test:core:$test_core_version"
testImplementation "androidx.test.ext:junit:$test_ext_version"
testImplementation "androidx.test:runner:$test_runner_version"
testImplementation "androidx.test:rules:$test_rules_version"
}
apply plugin: 'com.google.gms.google-services'
Versions below:
ext.timber_version = '4.7.1'
ext.timberkt_version = '1.5.1'
//Kotlin
ext.kotlin_version = '1.3.21'
ext.ktx_version = '1.0.1'
//Android
ext.appcompat_version = '1.0.2'
ext.lifecycle_ext_version = '2.0.0'
//UI
ext.constraint_version = '1.1.3'
ext.material_version = '1.0.0'
ext.recyclerview_version = '1.0.0'
ext.cardview_version = '1.0.0'
ext.material_drawer_version = '6.1.0'
ext.glide_version = '4.8.0'
//Adapters
ext.fastadapter_version = '3.3.1'
//Kodein
ext.kodein_version = '5.3.0'
//Firebase
ext.google_services_version = '4.2.0'
ext.fire_core_version = '16.0.7'
ext.fire_auth_version = '16.1.0'
ext.fire_store_version = '18.0.1'
ext.fire_storage_version = '16.0.5'
//Testing
ext.espresso_version = '3.1.0-beta02'
ext.robolectric_version = '4.0.2'
ext.junit_version = '4.12'
ext.test_core_version = '1.0.0'
ext.test_runner_version = '1.1.0'
ext.test_rules_version = '1.1.0'
ext.test_ext_version = '1.0.0'
I have managed to make it work with a version downgrade:
project build:
classpath 'com.google.gms:google-services:4.0.2'
classpath 'com.android.tools.build:gradle:3.3.1'
data module (where i have Firebase dependencies):
apply plugin: 'com.google.gms.google-services'
I hope they solve the bug soon
Did anyone find a workaround that doesn't involve downgrading Google Services Plugin version?
This only seems to happen if the project has an app and a module. I deleted the module and moved all the source files and resources into the app and this problem went away. I was able to use the latest version of 'com.google.gms:google-services' and 'com.android.tools.build:gradle'. Both the app crash and the NRE disappeared. I realize that this approach may not work for everyone, but it fixed my problem.
The same issue. GMS code is in separate module (not app) since it has its own package registered in GMS and app has many flavors with different packages.
My versions: gms 4.2.0 android gradle plugin: 3.4.0-rc02 gradle: 5.3.1
ps: rolled back to 4.0.2 for now
Are there any news concerning this issue?
Please see https://stackoverflow.com/questions/54441456/cant-update-to-com-google-gmsgoogle-services4-2-0
A workaround that works for me that does not involve downgrading com.google.gms:google-services
is to append
com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true
to the bottom of the build.gradle
file. Note that this is a different exception message and may not relate to the same issue. But maybe it helps.
Hi, any update about this?
Unfortunately, your workaround @shlusiak doesn't fix this problem (NullPointerException). 😞
Downgrading Google Services Plugin to 4.1.0
classpath "com.android.tools.build:gradle:3.4.0"
classpath "com.google.gms:google-services:4.1.0"
or downgrading Android Gradle Plugin to 3.2.0
classpath "com.android.tools.build:gradle:3.2.0"
classpath "com.google.gms:google-services:4.2.0"
are the only workarounds that work for me but none of them is a long term solution.
I encountered NPE , when I try to apply 'com.google.gms.google-services' plugin in anroid library module rather than app module.
I'm also having this issue, how can this be broken for so long, I'm using 4.1.0 until this gets resolved
This is also affecting our projects and from adopting 4.2.0.
Fixed in version 4.3.0. This issue should now be closed.
Hi, i just add this and its working Ionic 4.12.0
build.gradle(project) dependencies { classpath 'com.android.tools.build:gradle:3.3.0' classpath 'com.google.gms:google-services:4.3.2' }
build.gradle(module:app) dependencies { implementation fileTree(dir: 'libs', include: '*.jar') // SUB-PROJECT DEPENDENCIES START implementation(project(path: ":CordovaLib")) implementation "com.android.support:support-annotations:27.+" implementation "com.google.firebase:firebase-core:16.0.9" implementation "com.google.firebase:firebase-messaging:20.0.0" implementation 'com.google.firebase:firebase-analytics:17.2.1' // SUB-PROJECT DEPENDENCIES END }
This isn't necessary apply plugin: 'com.google.gms.google-services'
Describe the bug Hi! I encountered ununderstandable issue for me and it is hard to reproduce it. I can't upgrade the version of 'com.google.gms:google-services' plugin to version 4.2.0 but on 4.1.0 and lower everything works as expected.
To Reproduce Steps to reproduce the behavior:
Cause: java.lang.NullPointerException
Expected behavior Gradle syncs, project builds?
Desktop (please complete the following information):
Additional context Project contains of about 15 modules. Circa 1/3 of them have android plugin applied ("com.android.library"). Callstack below points at
:presentation
module and there you can findapply plugin: 'com.google.gms.google-services'
line, at the bottom of a file.presentation
module appliescom.android.library
plugin, not*.application
one. The result of--stacktrace
: