Implementing react-native-google-mobile-ads in EAS build

I did:

expo init
expo install expo-dev-client
expo install react-native-google-mobile-ads
eas build --profile development -p android

my app.config:

{
  "expo": {
    "name": "blue-kiwi-eas",
    "slug": "blue-kiwi-eas",
    "version": "1.0.0",
    "orientation": "portrait",
    "icon": "./assets/icon.png",
    "userInterfaceStyle": "light",
    "splash": {
      "image": "./assets/splash.png",
      "resizeMode": "contain",
      "backgroundColor": "#ffffff"
    },
    "updates": {
      "fallbackToCacheTimeout": 0
    },
    "assetBundlePatterns": ["**/*"],
    "ios": {
      "supportsTablet": true
    },
    "android": {
      "adaptiveIcon": {
        "foregroundImage": "./assets/adaptive-icon.png",
        "backgroundColor": "#FFFFFF"
      },
      "package": "com.basselturky.bluekiwieas"
    },
    "web": {
      "favicon": "./assets/favicon.png"
    },
    "extra": {
      "eas": {
        "projectId": "31e64390-279e-46cb-a2cf-980a743335ca"
      }
    }
  },
  "react-native-google-mobile-ads": {
    "android_app_id": "ca-app-pub-*******",
    "ios_app_id": "ca-app-pub-*******"
  }
}

then I installed the build on my android emulator.
I started the app with expo start --dev-client

Every time I press “a” to load the app on the emulator, the app crashes, no errors or anything.

I uninstalled react-native-google-mobile-ads and removed it from app.json

The app launched just fine.

What is going wrong?

Also, is expo-ads-admob deprecated? and can I use it with EAS?

  • Managed workflow
  • eas-cli version: Latest
  • Android Studio: Latest version

Hi!

expo-ads-admob is deprecated/ removed.

At a quick glance, your RN Google Mobile Ads setup looks correct and I’m not aware of a reason it should not work. I’d recommend debugging with adb logcat as described here to get the native error and then checking their repo for any similar issues. Let us know what error and/or resolution you find here, I’m sure others would be curious to know!

1 Like

Android Studio Logcat:

2022-10-11 23:24:20.743 8122-8122/com.basselturky.bluekiwieas D/AndroidRuntime: Shutting down VM
    
    
    --------- beginning of crash
2022-10-11 23:24:20.744 8122-8122/com.basselturky.bluekiwieas E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.basselturky.bluekiwieas, PID: 8122
    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:6988)
        at android.app.ActivityThread.installContentProviders(ActivityThread.java:6528)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6445)
        at android.app.ActivityThread.access$1300(ActivityThread.java:219)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1859)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7356)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
     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.ads.internal.client.zzee.attachInfo(com.google.android.gms:play-services-ads-lite@@21.2.0:22)
        at com.google.android.gms.ads.MobileAdsInitProvider.attachInfo(com.google.android.gms:play-services-ads-lite@@21.2.0:1)
        at android.app.ActivityThread.installProvider(ActivityThread.java:6983)
        	... 10 more

I made ad units for both android and IOS on google AdMob, they gave me an ad ID which I used in my app.json

Maybe there is a problem with these IDs, not confirmed or something.

I found out what was causing this Crash/Error.

I used Ad ID from AdMob Ad unit instead of App ID in app.json
Changed this:

  "react-native-google-mobile-ads": {
    "android_app_id": "ad unit id",
    "ios_app_id": "ad unit id"
  }

With this:

  "react-native-google-mobile-ads": {
    "android_app_id": "app id",
    "ios_app_id": "app id"
  }

Sorry for the inconvenience :slight_smile:

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.