Cordova-plugin-googlemaps: Application has stopped (Android)

Created on 21 Mar 2018  路  28Comments  路  Source: mapsplugin/cordova-plugin-googlemaps

I have this bug.
Yesterday I was building normally.
Today phonegap is compiling but when I install on Android I get this error:

03-21 15:06:10.381 10948-10948/? E/AndroidRuntime: FATAL EXCEPTION: main
                                                   Process: myapp.com, PID: 10948
                                                   java.lang.NoSuchMethodError: No static method checkNotNull(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; in class Lcom/google/android/gms/common/internal/zzbq; or its super classes (declaration of 'com.google.android.gms.common.internal.zzbq' appears in /data/app/myapp.com-2/base.apk)
                                                       at com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
                                                       at plugin.google.maps.CordovaGoogleMaps$1.run(CordovaGoogleMaps.java:209)
                                                       at android.app.Activity.runOnUiThread(Activity.java:5874)
                                                       at plugin.google.maps.CordovaGoogleMaps.initialize(CordovaGoogleMaps.java:72)
                                                       at org.apache.cordova.CordovaPlugin.privateInitialize(CordovaPlugin.java:57)
                                                       at org.apache.cordova.PluginManager.getPlugin(PluginManager.java:171)
                                                       at org.apache.cordova.PluginManager.startupPlugins(PluginManager.java:97)
                                                       at org.apache.cordova.PluginManager.init(PluginManager.java:86)
                                                       at org.apache.cordova.CordovaWebViewImpl.init(CordovaWebViewImpl.java:117)
                                                       at org.apache.cordova.CordovaActivity.init(CordovaActivity.java:149)
                                                       at org.apache.cordova.CordovaActivity.loadUrl(CordovaActivity.java:224)
                                                       at myapp.com.MyApp.onCreate(MyApp.java:39)
                                                       at android.app.Activity.performCreate(Activity.java:6687)
                                                       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1140)
                                                       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2631)
                                                       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2743)
                                                       at android.app.ActivityThread.-wrap12(ActivityThread.java)
                                                       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1490)
                                                       at android.os.Handler.dispatchMessage(Handler.java:102)
                                                       at android.os.Looper.loop(Looper.java:154)
                                                       at android.app.ActivityThread.main(ActivityThread.java:6165)
                                                       at java.lang.reflect.Method.invoke(Native Method)
                                                       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:888)
                                                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:778)
need more information

All 28 comments

Please share your project files on Github.

Same here, will do update on my github repo

Having the exact same issue.

The error i'm getting is:
java.lang.NoSuchMethodError: com.google.android.gms.common.internal.zzbq.checkNotNull

According to what i've read so far, the issue should be able to be resolved by updating some dependencies, going to try that now and update here if I manage something.

Without project files, how can I reproduce your issue?

I managed to resolve my issue, was able to build successfully with play services v4.26
and I added two lines that forced the dependencies for com.google.android.gms:play-services-maps & com.google.android.gms:play-services-location to latest in my build.gradle.

dependencies {
implementation fileTree(dir: 'libs', include: '*.jar')
// SUB-PROJECT DEPENDENCIES START
implementation(project(path: ":CordovaLib"))
compile "com.google.android.gms:play-services-maps:11.8.0"
compile "com.google.android.gms:play-services-location:11.8.0"
compile "com.android.support:support-core-utils:24.1.0"
compile "com.google.android.gms:play-services-location:+"
compile "com.android.support:support-v4:27.1.0"
compile "com.android.support:appcompat-v7:26.+"
compile "com.squareup.okhttp3:okhttp:3+"
// SUB-PROJECT DEPENDENCIES END
compile "com.google.android.gms:play-services-location:+"
compile "com.google.android.gms:play-services-maps:+"
}

After that it built successfully and the app did not crash on load anymore.

I am having the same problem on ionic. Using version 2.2.8 of the plugin. iOS working fine. If i remove the googlemaps plugin completely the app run fine. I have ci/cd so changing the android native app is not an option. I will work on providing a sample project today. You will need to use your own maps keys as a reminder when I submit.
cli packages: (/usr/local/lib/node_modules)
@ionic/cli-utils : 1.19.2
ionic (Ionic CLI) : 3.20.0
global packages:
cordova (Cordova CLI) : 8.0.0
local packages:
@ionic/app-scripts : 3.1.8
Cordova Platforms : android 7.0.0 ios 4.5.4
Ionic Framework : ionic-angular 3.9.2
System:
Android SDK Tools : 26.1.1
ios-deploy : 1.9.2
ios-sim : 6.1.2
Node : v8.9.4
npm : 5.6.0
OS : macOS High Sierra
Xcode : Xcode 9.2 Build version 9C40b
Environment Variables:
ANDROID_HOME : /Users/*/Library/Android/sdk
Misc: backend : pro

@DifferentialityDevelopment
How do you change your build.gradle files using cordova?
Is there a way of doing this with config.xml?

@lsilva23 I think you would need a custom hook. But I have not done that for the android gradle stuff. It might be best to wait for a fix on this from the plugin owners... something happened between 2.2.5 and the latest to create this break. I am sure it can be resolved on their end... hopefully.

I'm using the Ionic framework which uses cordova, you'll find the gradle file you need to edit under /platforms/android/app/build.gradle,
Look for // SUB-PROJECT DEPENDENCIES END
You'll have to put the two lines after that because before will cause it to be overwritten.
A custom hook could work too as StobyWan just mentioned. I don't remove and add my platform all that much so I've simply mentioned the fix in my project's README.MD so I don't forget about it.

The version I was using when it happened was 11.8.0 and after changing to + the issue went away.

@StobyWan
I guess there are two definitions of com.android.support:support-core-utils

This is not bug, it's just conflict with other plugin, such as the google-plus plugin.
Choosing what plugin is your responsibility. If conflict, you need to adjust them.

@wf9a5m75 This is my Project: http://sistema.99car.club/pdrcar.apk

Please share your project files on Github.

And on my build log in Phonegap I am getting this:
:app:lintVitalRelease/app/src/main/res/values/strings.xml:3: Error: "app_name" is not translated in "ar" (Arabic), "de" (German), "fr" (French), "hi" (Hindi), "ja" (Japanese), "nl" (Dutch), "pl" (Polish), "pt-PT" (Portuguese: Portugal), "ru" (Russian), "uk" (Ukrainian) [MissingTranslation]
Pdr Car Cliente
~~~
/app/src/main/res/values/strings.xml:4: Error: "launcher_name" is not translated in "ar" (Arabic), "de" (German), "fr" (French), "hi" (Hindi), "ja" (Japanese), "nl" (Dutch), "pl" (Polish), "pt-PT" (Portuguese: Portugal), "ru" (Russian), "uk" (Ukrainian) [MissingTranslation]
@string/app_name
~~~~
/app/src/main/res/values/strings.xml:5: Error: "activity_name" is not translated in "ar" (Arabic), "de" (German), "fr" (French), "hi" (Hindi), "ja" (Japanese), "nl" (Dutch), "pl" (Polish), "pt-PT" (Portuguese: Portugal), "ru" (Russian), "uk" (Ukrainian) [MissingTranslation]
@string/launcher_name
~~~~

Explanation for issues of type "MissingTranslation":
If an application has more than one locale, then all the strings declared
in one language should also be translated in all other languages.

If the string should not be translated, you can add the attribute
translatable="false" on the element, or you can define all your
non-translatable strings in a resource file called donottranslate.xml. Or,
you can ignore the issue with a tools:ignore="MissingTranslation"
attribute.

By default this detector allows regions of a language to just provide a
subset of the strings and fall back to the standard language strings. You
can require all regions to provide a full translation by setting the
environment variable ANDROID_LINT_COMPLETE_REGIONS.

You can tell lint (and other tools) which language is the default language
in your res/values/ folder by specifying tools:locale="languageCode" for
the root element in your resource file. (The tools prefix
refers to the namespace declaration http://schemas.android.com/tools.)

3 errors, 0 warnings

@wf9a5m75 I can't seem to agree on this, the app works fine but only causes this issue for me on the lowest supported android version of API 19, ie 4.4.4.
I don't necessarily think it's a bug with the plugin though, nevertheless making sure the app is built with the latest dependencies as I mentioned above seems to fix the issue.

@lsilva23 I don't think those translation issues are related to the crash.

@DifferentialityDevelopment
Are you talking about preference name="android-minSdkVersion" value="16" this?

@lsilva23 Does your app crash on startup or on install?
The error I had on startup was
java.lang.NoSuchMethodError: com.google.android.gms.common.internal.zzbq.checkNotNull
at com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)

@DifferentialityDevelopment On startup! It build successful on Phonegap and Install successful on Android 5.1/7.0

@lsilva23 Did you try the fix I stated earlier of modifying the build.gradle file?

@DifferentialityDevelopment I can't find my build.gradle file, I will post my project files so you can see how I am doing this

I fixed!
Just had to put those variables:

<plugin name="cordova-plugin-googlemaps" spec="^2.2.8">
        <variable name="PLAY_SERVICES_VERSION" value="+" />
        <variable name="ANDROID_SUPPORT_V4_VERSION" value="24.1.0" />
        <variable name="LOCATION_WHEN_IN_USE_DESCRIPTION" value="Aplicativo precisa de sua localiza莽茫o!" />
        <variable name="LOCATION_ALWAYS_USAGE_DESCRIPTION" value="Aplicativo precisa de sua localiza莽茫o!" />
    </plugin>

Thank you guys for your time!

Lol, glad you got it fixed.

@DifferentialityDevelopment

If you were a plugin developer, and someone reports only logs, what whould you do?
It's not only one, tons of people.
So you would spend your private time for debugging other people problems.
Would you like it?

I don't like it. That's why I ask for everyone to share the project files. Because this is shortest way to solve the problem.
I asked "please share your project files on GitHub", but I don't specify as public repository.
If you don't want to discover your code in public, you just buy a private repo.

You don't agree it? Please just debug the issue by yourself.

@wf9a5m75 I will try to upload my project file (plugin) tomorrow (23 March) from airport, because then I get some time do rebuild my project. I will let you know about it if you want, ok?

Yeah, let me know when you are ready please.

Adding \

@hackeo Ah! Thanks for that!

Plugin configuration is responsibility of app developer, not me, because it's depends on when, and what other plugins you install. In the past, so many people claimed <variable name="PLAY_SERVICES_VERSION" value="+" /> because conflict with other plugins.
You can select +, but take the risk with your responsibility please.

Since it seems the reason is the build configuration, and everyone are solved thier problems, I close this thread.

Was this page helpful?
0 / 5 - 0 ratings