sunnycupertino / cordova-plugin-admob-simple

Cordova plugin allowing Admob interstitials and banner ads.
MIT License
164 stars 150 forks source link

App crashes on startup #38

Closed blukis closed 5 years ago

blukis commented 5 years ago

My app crashes immediately on startup, built using PhoneGap Build. This wasn't happening maybe a week ago. (Suspect plugin incompatibility with the latest Admob SDK?)

I think the relevant excerpt from the Android debug log, at the crash:

10-06 10:29:03.551 5605 5605 D AndroidRuntime: Shutting down VM 10-06 10:29:03.552 5605 5605 E AndroidRuntime: FATAL EXCEPTION: main 10-06 10:29:03.552 5605 5605 E AndroidRuntime: Process: us.plurib.highlight1, PID: 5605 10-06 10:29:03.552 5605 5605 E AndroidRuntime: java.lang.RuntimeException: Unable to get provider com.google.android.gms.ads.MobileAdsInitProvider: java.lang.IllegalStateException: 10-06 10:29:03.552 5605 5605 E AndroidRuntime: 10-06 10:29:03.552 5605 5605 E AndroidRuntime: ** 10-06 10:29:03.552 5605 5605 E AndroidRuntime: The Google Mobile Ads SDK was initialized incorrectly. AdMob publishers 10-06 10:29:03.552 5605 5605 E AndroidRuntime: should follow the instructions here: https://goo.gl/fQ2neu to add a valid 10-06 10:29:03.552 5605 5605 E AndroidRuntime: App ID inside the AndroidManifest. Google Ad Manager publishers should 10-06 10:29:03.552 5605 5605 E AndroidRuntime: follow instructions here: https://goo.gl/h17b6x. 10-06 10:29:03.552 5605 5605 E AndroidRuntime: ** 10-06 10:29:03.552 5605 5605 E AndroidRuntime: 10-06 10:29:03.552 5605 5605 E AndroidRuntime: 10-06 10:29:03.552 5605 5605 E AndroidRuntime: at android.app.ActivityThread.installProvider(ActivityThread.java:6319) 10-06 10:29:03.552 5605 5605 E AndroidRuntime: at android.app.ActivityThread.installContentProviders(ActivityThread.java:5882) 10-06 10:29:03.552 5605 5605 E AndroidRuntime: at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5803) 10-06 10:29:03.552 5605 5605 E AndroidRuntime: at android.app.ActivityThread.-wrap1(Unknown Source:0) 10-06 10:29:03.552 5605 5605 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1666) 10-06 10:29:03.552 5605 5605 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:105) 10-06 10:29:03.552 5605 5605 E AndroidRuntime: at android.os.Looper.loop(Looper.java:251) 10-06 10:29:03.552 5605 5605 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:6572) 10-06 10:29:03.552 5605 5605 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method) 10-06 10:29:03.552 5605 5605 E AndroidRuntime: at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) 10-06 10:29:03.552 5605 5605 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767) 10-06 10:29:03.552 5605 5605 E AndroidRuntime: Caused by: java.lang.IllegalStateException: 10-06 10:29:03.552 5605 5605 E AndroidRuntime: 10-06 10:29:03.552 5605 5605 E AndroidRuntime: ** 10-06 10:29:03.552 5605 5605 E AndroidRuntime: The Google Mobile Ads SDK was initialized incorrectly. AdMob publishers 10-06 10:29:03.552 5605 5605 E AndroidRuntime: should follow the instructions here: https://goo.gl/fQ2neu to add a valid 10-06 10:29:03.552 5605 5605 E AndroidRuntime: App ID inside the AndroidManifest. Google Ad Manager publishers should 10-06 10:29:03.552 5605 5605 E AndroidRuntime: follow instructions here: https://goo.gl/h17b6x. 10-06 10:29:03.552 5605 5605 E AndroidRuntime: ** 10-06 10:29:03.552 5605 5605 E AndroidRuntime: 10-06 10:29:03.552 5605 5605 E AndroidRuntime: 10-06 10:29:03.552 5605 5605 E AndroidRuntime: at com.google.android.gms.internal.ads.zzmn.attachInfo(Unknown Source:17) 10-06 10:29:03.552 5605 5605 E AndroidRuntime: at com.google.android.gms.ads.MobileAdsInitProvider.attachInfo(Unknown Source:3) 10-06 10:29:03.552 5605 5605 E AndroidRuntime: at android.app.ActivityThread.installProvider(ActivityThread.java:6316) 10-06 10:29:03.552 5605 5605 E AndroidRuntime: ... 10 more 10-06 10:29:03.553 1591 4805 D ActivityManager: New dropbox entry: us.plurib.highlight1, data_app_crash, 6fc85111-8fef-4c4b-8d14-bc1c86687e82 10-06 10:29:03.554 1591 4805 W ActivityManager: Force finishing activity us.plurib.highlight1/.HighlighterDraw 10-06 10:29:03.556 1591 4805 D ActivityTrigger: ActivityTrigger activityPauseTrigger 10-06 10:29:03.560 1181 1181 I JavaDumper:main: dest_path: /data/system/log/jd_dropboxfiles/data_app_crash@1538839743560.txt 10-06 10:29:03.560 1181 1181 I JavaDumper:main: tot_read: 2329, tot_write: 2329 10-06 10:29:03.560 1181 1181 I JavaDumper:main: Successfully copied dropbox file to /data/system/log/jd_dropboxfiles/data_app_crash@1538839743560.txt 10-06 10:29:03.560 1181 1181 D clmlib : Got activities:0x00000008 10-06 10:29:03.560 1181 1181 I JavaDumper:JavaDumperThread: addEvent: data_app_crash@1538839743560.txt processName: us.plurib.highlight1 10-06 10:29:03.560 1181 1262 I JavaDumper:JavaDumperThread: Event: data_app_crash@1538839743560.txt TimeStamp: 1538839743 10-06 10:29:03.561 1591 1610 I ActivityManager: Showing crash dialog for package us.plurib.highlight1 u0 10-06 10:29:03.562 1181 1262 W JavaDumper:JavaDumper: Could not init dump dir: Unknown error -95 10-06 10:29:03.562 1181 1262 E JavaDumper:FW: utils.c(257): mkdir (/data/crashdata) failed. File exists 10-06 10:29:03.563 1181 1262 E JavaDumper:FW: ramdump_framework.c(362): fp is NULL 10-06 10:29:03.563 1181 1262 E JavaDumper:FW: ramdump_framework.c(541): Read-only file system 10-06 10:29:03.564 1591 1609 D CompatibilityInfo: mCompatibilityFlags - 10 10-06 10:29:03.565 1591 1609 D CompatibilityInfo: applicationDensity - 320 10-06 10:29:03.565 1591 1609 D CompatibilityInfo: applicationScale - 1.0 10-06 10:29:03.566 1591 4802 D CompatibilityInfo: mCompatibilityFlags - 10 10-06 10:29:03.566 1591 4802 D CompatibilityInfo: applicationDensity - 320 10-06 10:29:03.566 1591 4802 D CompatibilityInfo: applicationScale - 1.0

blukis commented 5 years ago

Closing for now. The error remains even when I remove this plugin. Doing more homework first.....

tyshawngaines commented 5 years ago

I am getting the same issue, my app began to work again after doing cordova plugin remove cordova-plugin-admob-simple, then doing cordova clean android. No admob but the app works again.

blukis commented 5 years ago

OK, I had another plugin that also caused a very similar error. Reopening this issue, as I believe it applies to this plugin as well. (Presumably both plugins have the same issue.)

I would be happy to provide a bare-bones app that has this problem, but I'd bet including this plugin in probably any app triggers a crash on startup.

blukis commented 5 years ago

Found a workaround: the goo.gl link in the error message above refers to requiring a <meta-data> node in the ApplicationManifest.xml or this crash will happen. Inserting it manually seems to solve the crashing issue. (Add the following into the config.xml somewhere.)

<config-file parent="./application" target="AndroidManifest.xml"> <meta-data android:name="com.google.android.gms.ads.APPLICATION_ID" android:value="ca-app-pub-XXXXXXXXXXXXXXXX~XXXXXXXXXX"/> </config-file>

(Note, replace with your own app ID. It's not the same as the ad unit ID though it looks similar. Can be found at "Admob > apps > YourApp > app settings > App ID".) If this is the preferred solution, readme should be updated to reflect it, I suppose.

tyshawngaines commented 5 years ago

My previous option's was to try a different plugin but ill give this a try as well, thanks!

berengergermain commented 5 years ago

Found a workaround: the goo.gl link in the error message above refers to requiring a <meta-data> node in the ApplicationManifest.xml or this crash will happen. Inserting it manually seems to solve the crashing issue. (Add the following into the config.xml somewhere.)

<config-file parent="./application" target="AndroidManifest.xml"> <meta-data android:name="com.google.android.gms.ads.APPLICATION_ID" android:value="ca-app-pub-XXXXXXXXXXXXXXXX~XXXXXXXXXX"/> </config-file>

That works fine for me. For those who still have an (new) error when building, don't forget to add xmlns:android="http://schemas.android.com/apk/res/android" attribute to the <widget> tag ;)

ManoloPololo commented 5 years ago

Found a workaround: the goo.gl link in the error message above refers to requiring a <meta-data> node in the ApplicationManifest.xml or this crash will happen. Inserting it manually seems to solve the crashing issue. (Add the following into the config.xml somewhere.) <config-file parent="./application" target="AndroidManifest.xml"> <meta-data android:name="com.google.android.gms.ads.APPLICATION_ID" android:value="ca-app-pub-XXXXXXXXXXXXXXXX~XXXXXXXXXX"/> </config-file>

That works fine for me. For those who still have an (new) error when building, don't forget to add xmlns:android="http://schemas.android.com/apk/res/android" attribute to the <widget> tag ;)

Thank you, berengergermain. The answer of blukis wasn't working entirely for me, but then I added that line to the widget tag at the config.xml and then my problem become solved.

Winamp9 commented 5 years ago

and what about ios, why it does not work there

Winamp9 commented 5 years ago

Do need to use this instruction to display ads in ios? https://developers.google.com/admob/ios/quick-start

sunnycupertino commented 5 years ago

Ok thanks guys, added it to readme.

Shiba3006 commented 5 years ago

Found a workaround: the goo.gl link in the error message above refers to requiring a <meta-data> node in the ApplicationManifest.xml or this crash will happen. Inserting it manually seems to solve the crashing issue. (Add the following into the config.xml somewhere.)

<config-file parent="./application" target="AndroidManifest.xml"> <meta-data android:name="com.google.android.gms.ads.APPLICATION_ID" android:value="ca-app-pub-XXXXXXXXXXXXXXXX~XXXXXXXXXX"/> </config-file>

(Note, replace with your own app ID. It's not the same as the ad unit ID though it looks similar. Can be found at "Admob > apps > YourApp > app settings > App ID".) If this is the preferred solution, readme should be updated to reflect it, I suppose.

where can i find this config.xml ????

sunnycupertino commented 5 years ago

You can follow the links here https://github.com/sunnycupertino/cordova-plugin-admob-simple#coding-details-load-interstitial-first-and-show-later

"Add your app ID as described here for Android, or here for iOS."