admob-plus: App crashes immediately after opening

Describe the bug My app crashes immediately after launching the app. I excluded all plugins except the admob-plus plugin and my app still crashes, so I assume the crash is related to the plugin.

I build my app in the cloud using Ionic Appflow (because I am a novice and I don’t have the skill to build locally). I only build for Android.

In Google Play Console I have the following crash error: dalvik.system.BaseDexClassLoader.findClass java.lang.ClassNotFoundException

error details: type: java.lang.RuntimeException Exception java.lang.RuntimeException: at android.app.LoadedApk.makeApplicationInner (LoadedApk.java:1573) at android.app.LoadedApk.makeApplicationInner (LoadedApk.java:1502) at android.app.ActivityThread.handleBindApplication (ActivityThread.java:7553) at android.app.ActivityThread.-$$Nest$mhandleBindApplication at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2400) at android.os.Handler.dispatchMessage (Handler.java:106) at android.os.Looper.loopOnce (Looper.java:226) at android.os.Looper.loop (Looper.java:313) at android.app.ActivityThread.main (ActivityThread.java:8757) at java.lang.reflect.Method.invoke at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:571) at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1067) Caused by java.lang.ClassNotFoundException: at dalvik.system.BaseDexClassLoader.findClass (BaseDexClassLoader.java:259) at java.lang.ClassLoader.loadClass (ClassLoader.java:379) at java.lang.ClassLoader.loadClass (ClassLoader.java:312) at android.app.AppComponentFactory.instantiateApplication (AppComponentFactory.java:76) at androidx.core.app.CoreComponentFactory.instantiateApplication (CoreComponentFactory.java:52) at android.app.Instrumentation.newApplication (Instrumentation.java:1232) at android.app.LoadedApk.makeApplicationInner (LoadedApk.java:1565)

To Reproduce Steps to reproduce the behavior:

  1. Include the plugin in config.xml (see below)
  2. Build app in Ionic appflow (see details belows)
  3. Download apk, install apk
  4. Open app

Expected behavior App does not crash when launching.

Environment I build my app in the cloud using Ionic appflow.

This is the environment info from the build log: ±--------------------±---------+ | Build Summary | ±--------------------±---------+ | Job ID | 8569156 | | Node.js version | v18.12.1 | | Cordova CLI version | 11.0.0 | | npm version | 8.19.3 | | yarn version | 1.22.19 | ±--------------------±---------+

I run my build using an additional environment setting (which I found online, without this setting my build gives an error): key: OVERRIDE_JAVA_VERSION value: 11

Additional context Below my config.xml configuration related to the plugin. My results is the same (crash on app open) when I include or exclude all my other plugins, which is why I don’t mention those in the description below.

My widget config contains: xmlns:android=“http://schemas.android.com/apk/res/android

Inside of my config.xml:

<plugin name="admob-plus-cordova" spec="1.28.0">
    <variable name="APP_ID_ANDROID" value="ca-app-pub-7462917676626966~2253912345" />
</plugin>

<platform name="android">
    <edit-config file="AndroidManifest.xml" mode="merge" target="/manifest/application" xmlns:android="http://schemas.android.com/apk/res/android">
        <meta-data 
        android:name="com.google.android.gms.ads.APPLICATION_ID"
        android:value="ca-app-pub-7462917676626966~2253912345" /> --> actual id with some numbers changed (not test-id)
    </edit-config>
</platform>

<preference name="AndroidXEnabled" value="true" />
<plugin name="cordova-plugin-androidx-adapter" source="npm" />

<preference name="android-minSdkVersion" value="28" /> --> this was first 22, I changed to 28 (both have same result)
<preference name="android-targetSdkVersion" value="31" />
<preference name="android-compileSdkVersion" value="31" />

My package.json does not contain anything relevant to this plugin (note I am building in the cloud using ionic appflow, so I think this is ok, however feel free offcourse to correct me)

Some info (not sure if relevant): I successfully used before cordova-admob-pro with my admob id. I am switching to this plugin because I fail to build cordova-admob-pro with a play services version >= 20 I tried myself to investigate similar problems. I looked at this thread https://github.com/admob-plus/admob-plus/issues/379 but the clue there was the wrong id was used. ChatGPT and Bing Chat also failed to provide me a solution 😃

Many thanks in advance for anybody willing to help me! Michiel

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 1
  • Comments: 28 (4 by maintainers)

Most upvoted comments

Sorry, the error makes sense. The com.google.android.gms.ads.APPLICATION_ID was missing. Might have gotten missed when the plugin was updated. I removed the plugin and re-added it in the format cordova plugin add admob-plus-cordova --save --variable APP_ID_ANDROID=ca-app-pub-xxx~xxx --variable APP_ID_IOS=ca-app-pub-xxx~xxx and it worked fine after that. Sorry about that. Didn’t mean to hijack this thread and I am not sure if the OP had the same issue, but my one got resolved once I reinstalled the plugin with the App Id.

@ratson Thanks for getting back to me. I was able to grab the error in Logcat. It says this:

2023-05-30 23:28:24.124 7741-7741/? E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.app.mobile, PID: 7741
    java.lang.RuntimeException: Unable to get provider com.google.android.gms.ads.MobileAdsInitProvider: java.lang.IllegalStateException: 
    
    ******************************************************************************
    * Invalid application ID. Follow instructions here:                          *
    * https://googlemobileadssdk.page.link/admob-android-update-manifest         *
    * to find your app ID.                                                       *
    ******************************************************************************
    
    
        at android.app.ActivityThread.installProvider(ActivityThread.java:8328)
        at android.app.ActivityThread.installContentProviders(ActivityThread.java:7828)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7577)
        at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2400)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loopOnce(Looper.java:226)
        at android.os.Looper.loop(Looper.java:313)
        at android.app.ActivityThread.main(ActivityThread.java:8757)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)
     Caused by: java.lang.IllegalStateException: 
    
    ******************************************************************************
    * Invalid application ID. Follow instructions here:                          *
    * https://googlemobileadssdk.page.link/admob-android-update-manifest         *
    * to find your app ID.                                                       *
    ******************************************************************************
    
    
        at com.google.android.gms.internal.ads.zzbjr.attachInfo(com.google.android.gms:play-services-ads-lite@@20.6.0:22)
        at com.google.android.gms.ads.MobileAdsInitProvider.attachInfo(com.google.android.gms:play-services-ads-lite@@20.6.0:1)
        at android.app.ActivityThread.installProvider(ActivityThread.java:8323)
        	... 11 more