cordova-plugin-googlemaps icon indicating copy to clipboard operation
cordova-plugin-googlemaps copied to clipboard

Application has stopped (Android)

Open lsilva23 opened this issue 8 years ago • 28 comments

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)

lsilva23 avatar Mar 21 '18 19:03 lsilva23

Please share your project files on Github.

wf9a5m75 avatar Mar 21 '18 19:03 wf9a5m75

Same here, will do update on my github repo

wojtal26 avatar Mar 22 '18 11:03 wojtal26

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?

wf9a5m75 avatar Mar 22 '18 12:03 wf9a5m75

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

StobyWan avatar Mar 22 '18 13:03 StobyWan

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

lsilva23 avatar Mar 22 '18 13:03 lsilva23

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

StobyWan avatar Mar 22 '18 13:03 StobyWan

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 avatar Mar 22 '18 14:03 wf9a5m75

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

lsilva23 avatar Mar 22 '18 14:03 lsilva23

Please share your project files on Github.

wf9a5m75 avatar Mar 22 '18 14:03 wf9a5m75

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

lsilva23 avatar Mar 22 '18 14:03 lsilva23

@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 avatar Mar 22 '18 14:03 lsilva23

@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 avatar Mar 22 '18 14:03 lsilva23

@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

lsilva23 avatar Mar 22 '18 14:03 lsilva23

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!

lsilva23 avatar Mar 22 '18 14:03 lsilva23