google / play-services-plugins

Plugins to help with using Google Play services SDK.
https://developers.google.com/android/guides/overview
Apache License 2.0
471 stars 138 forks source link

Can't upgrade google-play-services to 4.2.0. NullPointerException, no message #22

Closed mateuszkwiecinski closed 3 years ago

mateuszkwiecinski commented 6 years ago

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:

  1. Set plugin version to 4.1.0 in your project
  2. Verify gradle can configure itself, project builds
  3. Set plugin version to 4.2.0
  4. The only visible message is 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 find apply plugin: 'com.google.gms.google-services' line, at the bottom of a file. presentation module applies com.android.library plugin, not *.application one. The result of --stacktrace:

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':presentation'.
> java.lang.NullPointerException

* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Exception is:
org.gradle.api.ProjectConfigurationException: A problem occurred configuring project ':presentation'.
        at org.gradle.configuration.project.LifecycleProjectEvaluator.wrapException(LifecycleProjectEvaluator.java:80)
        at org.gradle.configuration.project.LifecycleProjectEvaluator.addConfigurationFailure(LifecycleProjectEvaluator.java:73)
        at org.gradle.configuration.project.LifecycleProjectEvaluator.access$600(LifecycleProjectEvaluator.java:54)
        at org.gradle.configuration.project.LifecycleProjectEvaluator$NotifyAfterEvaluate.run(LifecycleProjectEvaluator.java:204)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:301)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:293)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:175)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91)
        at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
        at org.gradle.configuration.project.LifecycleProjectEvaluator$EvaluateProject$1.run(LifecycleProjectEvaluator.java:112)
        at org.gradle.internal.Factories$1.create(Factories.java:25)
        at org.gradle.internal.work.DefaultWorkerLeaseService.withLocks(DefaultWorkerLeaseService.java:183)
        at org.gradle.internal.work.StopShieldingWorkerLeaseService.withLocks(StopShieldingWorkerLeaseService.java:40)
        at org.gradle.api.internal.project.DefaultProjectStateRegistry$ProjectStateImpl.withProjectLock(DefaultProjectStateRegistry.java:226)
        at org.gradle.api.internal.project.DefaultProjectStateRegistry$ProjectStateImpl.withMutableState(DefaultProjectStateRegistry.java:220)
        at org.gradle.api.internal.project.DefaultProjectStateRegistry$ProjectStateImpl.withMutableState(DefaultProjectStateRegistry.java:186)
        at org.gradle.configuration.project.LifecycleProjectEvaluator$EvaluateProject.run(LifecycleProjectEvaluator.java:96)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:301)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:293)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:175)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91)
        at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
        at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:68)
        at org.gradle.api.internal.project.DefaultProject.evaluate(DefaultProject.java:687)
        at org.gradle.api.internal.project.DefaultProject.evaluate(DefaultProject.java:140)
        at org.gradle.execution.TaskPathProjectEvaluator.configure(TaskPathProjectEvaluator.java:35)
        at org.gradle.execution.TaskPathProjectEvaluator.configureHierarchy(TaskPathProjectEvaluator.java:62)
        at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:41)
        at org.gradle.initialization.DefaultGradleLauncher$ConfigureBuild.run(DefaultGradleLauncher.java:286)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:301)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:293)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:175)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91)
        at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
        at org.gradle.initialization.DefaultGradleLauncher.configureBuild(DefaultGradleLauncher.java:194)
        at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:150)
        at org.gradle.initialization.DefaultGradleLauncher.executeTasks(DefaultGradleLauncher.java:133)
        at org.gradle.internal.invocation.GradleBuildController$1.execute(GradleBuildController.java:79)
        at org.gradle.internal.invocation.GradleBuildController$1.execute(GradleBuildController.java:76)
        at org.gradle.internal.invocation.GradleBuildController$3.create(GradleBuildController.java:103)
        at org.gradle.internal.invocation.GradleBuildController$3.create(GradleBuildController.java:96)
        at org.gradle.internal.work.DefaultWorkerLeaseService.withLocks(DefaultWorkerLeaseService.java:183)
        at org.gradle.internal.work.StopShieldingWorkerLeaseService.withLocks(StopShieldingWorkerLeaseService.java:40)
        at org.gradle.internal.invocation.GradleBuildController.doBuild(GradleBuildController.java:96)
        at org.gradle.internal.invocation.GradleBuildController.run(GradleBuildController.java:76)
        at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28)
        at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
        at org.gradle.tooling.internal.provider.ValidatingBuildActionRunner.run(ValidatingBuildActionRunner.java:32)
        at org.gradle.launcher.exec.RunAsBuildOperationBuildActionRunner$3.run(RunAsBuildOperationBuildActionRunner.java:49)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:301)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:293)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:175)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91)
        at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
        at org.gradle.launcher.exec.RunAsBuildOperationBuildActionRunner.run(RunAsBuildOperationBuildActionRunner.java:44)
        at org.gradle.tooling.internal.provider.SubscribableBuildActionRunner.run(SubscribableBuildActionRunner.java:51)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter$1.transform(InProcessBuildActionExecuter.java:47)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter$1.transform(InProcessBuildActionExecuter.java:44)
        at org.gradle.composite.internal.DefaultRootBuildState.run(DefaultRootBuildState.java:79)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:44)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:30)
        at org.gradle.launcher.exec.BuildTreeScopeBuildActionExecuter.execute(BuildTreeScopeBuildActionExecuter.java:39)
        at org.gradle.launcher.exec.BuildTreeScopeBuildActionExecuter.execute(BuildTreeScopeBuildActionExecuter.java:25)
        at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:78)
        at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:52)
        at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:62)
        at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:34)
        at org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:36)
        at org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:25)
        at org.gradle.tooling.internal.provider.ParallelismConfigurationBuildActionExecuter.execute(ParallelismConfigurationBuildActionExecuter.java:43)
        at org.gradle.tooling.internal.provider.ParallelismConfigurationBuildActionExecuter.execute(ParallelismConfigurationBuildActionExecuter.java:29)
        at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:59)
        at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:31)
        at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:59)
        at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:44)
        at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:46)
        at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:30)
        at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:67)
        at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
        at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:37)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
        at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
        at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
        at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:74)
        at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:72)
        at org.gradle.util.Swapper.swap(Swapper.java:38)
        at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
        at org.gradle.launcher.daemon.server.exec.LogAndCheckHealth.execute(LogAndCheckHealth.java:55)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
        at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:62)
        at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
        at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:81)
        at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
        at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50)
        at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:295)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
        at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
Caused by: com.android.build.gradle.internal.crash.ExternalApiUsageException: java.lang.NullPointerException
        at com.android.build.gradle.internal.ApiObjectFactory.create(ApiObjectFactory.java:137)
        at com.android.build.gradle.BasePlugin.createAndroidTasks(BasePlugin.java:772)
        at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:81)
        at com.android.build.gradle.BasePlugin.lambda$createTasks$4(BasePlugin.java:646)
        at com.android.build.gradle.internal.crash.CrashReporting$afterEvaluate$1.execute(crash_reporting.kt:37)
        at com.android.build.gradle.internal.crash.CrashReporting$afterEvaluate$1.execute(crash_reporting.kt)
        at org.gradle.configuration.internal.DefaultListenerBuildOperationDecorator$BuildOperationEmittingAction$1$1.run(DefaultListenerBuildOperationDecorator.java:157)
        at org.gradle.configuration.internal.DefaultUserCodeApplicationContext.reapply(DefaultUserCodeApplicationContext.java:58)
        at org.gradle.configuration.internal.DefaultListenerBuildOperationDecorator$BuildOperationEmittingAction$1.run(DefaultListenerBuildOperationDecorator.java:154)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:301)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:293)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:175)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91)
        at org.gradle.configuration.internal.DefaultListenerBuildOperationDecorator$BuildOperationEmittingAction.execute(DefaultListenerBuildOperationDecorator.java:151)
        at org.gradle.internal.event.BroadcastDispatch$ActionInvocationHandler.dispatch(BroadcastDispatch.java:91)
        at org.gradle.internal.event.BroadcastDispatch$ActionInvocationHandler.dispatch(BroadcastDispatch.java:80)
        at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:42)
        at org.gradle.internal.event.BroadcastDispatch$SingletonDispatch.dispatch(BroadcastDispatch.java:230)
        at org.gradle.internal.event.BroadcastDispatch$SingletonDispatch.dispatch(BroadcastDispatch.java:149)
        at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:58)
        at org.gradle.internal.event.BroadcastDispatch$CompositeDispatch.dispatch(BroadcastDispatch.java:324)
        at org.gradle.internal.event.BroadcastDispatch$CompositeDispatch.dispatch(BroadcastDispatch.java:234)
        at org.gradle.internal.event.ListenerBroadcast.dispatch(ListenerBroadcast.java:140)
        at org.gradle.internal.event.ListenerBroadcast.dispatch(ListenerBroadcast.java:37)
        at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
        at com.sun.proxy.$Proxy26.afterEvaluate(Unknown Source)
        at org.gradle.configuration.project.LifecycleProjectEvaluator$NotifyAfterEvaluate$1.execute(LifecycleProjectEvaluator.java:191)
        at org.gradle.configuration.project.LifecycleProjectEvaluator$NotifyAfterEvaluate$1.execute(LifecycleProjectEvaluator.java:188)
        at org.gradle.api.internal.project.DefaultProject.stepEvaluationListener(DefaultProject.java:1413)
        at org.gradle.configuration.project.LifecycleProjectEvaluator$NotifyAfterEvaluate.run(LifecycleProjectEvaluator.java:197)
        ... 100 more
Caused by: java.lang.NullPointerException
        at org.gradle.api.internal.tasks.DefaultTaskDependency.add(DefaultTaskDependency.java:184)
        at org.gradle.api.internal.AbstractTask$10.run(AbstractTask.java:378)
        at org.gradle.api.internal.tasks.TaskMutator.mutate(TaskMutator.java:38)
        at org.gradle.api.internal.AbstractTask.dependsOn(AbstractTask.java:376)
        at com.google.gms.googleservices.GoogleServicesPlugin.handleVariant(GoogleServicesPlugin.groovy:206)
        at org.gradle.internal.metaobject.BeanDynamicObject$MetaClassAdapter.invokeMethod(BeanDynamicObject.java:479)
        at org.gradle.internal.metaobject.BeanDynamicObject.tryInvokeMethod(BeanDynamicObject.java:191)
        at org.gradle.internal.metaobject.ConfigureDelegate.invokeMethod(ConfigureDelegate.java:78)
        at com.google.gms.googleservices.GoogleServicesPlugin$_setupPlugin_closure6.doCall(GoogleServicesPlugin.groovy:148)
        at org.gradle.util.ClosureBackedAction.execute(ClosureBackedAction.java:70)
        at org.gradle.util.ConfigureUtil.configureTarget(ConfigureUtil.java:154)
        at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:105)
        at org.gradle.util.ConfigureUtil$WrappedConfigureAction.execute(ConfigureUtil.java:166)
        at org.gradle.internal.ImmutableActionSet$SingletonSet.execute(ImmutableActionSet.java:225)
        at org.gradle.api.internal.DefaultDomainObjectCollection.doAdd(DefaultDomainObjectCollection.java:250)
        at org.gradle.api.internal.DefaultDomainObjectCollection.add(DefaultDomainObjectCollection.java:239)
        at com.android.build.gradle.LibraryExtension.addVariant(LibraryExtension.java:93)
        at com.android.build.gradle.internal.ApiObjectFactory.create(ApiObjectFactory.java:134)
        ... 129 more

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.0-rc-1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 12s
gaborbiro commented 5 years ago

Any suggestions for this? Happening to me too exactly as described. I tried rebuild and clear cache&restart as well. No good.

HirogaKatageri commented 5 years ago

With Android Studio 3.3 Stable, I have also encountered this issue.

ginngi commented 5 years ago

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.

mdawid commented 5 years ago

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.

FilippoVigani commented 5 years ago

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.

achiose commented 5 years ago

Same issue here. Android studio 3.3 and GPS 4.2.0.

zhiqiao commented 5 years ago

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?

achiose commented 5 years ago

For me it always happens when trying to add the google.gms.service plugin inside an android library plugin. It automatically throws the NPE.

FilippoVigani commented 5 years ago

@zhiqiao https://github.com/VeegaP/GooglePlayServicesNPE This causes NPE, although I haven't reproduced the Firebase not initialized issue on a small project

davidmotson commented 5 years ago

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?

achiose commented 5 years ago

@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?

davidmotson commented 5 years ago

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.

FilippoVigani commented 5 years ago

@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?

davidmotson commented 5 years ago

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?

FilippoVigani commented 5 years ago

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.

PhantomLord72 commented 5 years ago

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

davidmotson commented 5 years ago

@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

rachitmishra commented 5 years ago

Config

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)

Issues

  1. 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.

  2. Updating classpath 'com.google.gms:google-services:4.1.0' to 4.2.0 causes NullPointerException at build without any description.

davidliu commented 5 years ago

@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.

LouisCAD commented 5 years ago

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…

samuelkristianto1 commented 5 years ago

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

HirogaKatageri commented 5 years ago

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'
juanaviladev commented 5 years ago

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

ziem commented 5 years ago

Did anyone find a workaround that doesn't involve downgrading Google Services Plugin version?

vijtheveg commented 5 years ago

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.

andreya108 commented 5 years ago

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

lanedas commented 5 years ago

Are there any news concerning this issue?

shlusiak commented 5 years ago

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.

gagan-3035 commented 5 years ago

Hi, any update about this?

ziem commented 5 years ago

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.

vkvashistha commented 5 years ago

I encountered NPE , when I try to apply 'com.google.gms.google-services' plugin in anroid library module rather than app module.

eman1986 commented 5 years ago

I'm also having this issue, how can this be broken for so long, I'm using 4.1.0 until this gets resolved

sistr22 commented 5 years ago

This is also affecting our projects and from adopting 4.2.0.

LouisCAD commented 5 years ago

Fixed in version 4.3.0. This issue should now be closed.

sandrarj commented 5 years ago

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'