skip to Main Content

I’m experiencing an issue where my Expo React Native app is crashing immediately on start after installing the react-native-google-mobile-ads package.

UPDATED:

I’ve taken the following steps so far…

  • Install using npx expo install react-native-google-mobile-ads
  • Update app.json per the documentation (obscured my IDs):
"plugins": [
      "expo-router",
      "expo-localization",
      "expo-apple-authentication",
      [
        "react-native-google-mobile-ads",
        {
          "androidAppId": "ca-app-pub-<id obscured>",
          "iosAppId": "ca-app-pub-<id obscured>"
        }
      ]
    ],
  • Create a development build
  • Install development build on device

Curious if I’m still doing something incorrectly here. Any help is appreciated!

2

Answers


    1. It should be app.config.js not app.config.json
    2. There is no need to have both app.config.js and app.json. Both files can exist but ultimately their purpose is to return a JS object describing the configuration of your Expo app. Personally I use app.config.js because it allows me to dynamically calculate some of the Expo properties based on the build environment.
    export default ({config}) => {
      let appConfig;
    
      if (process?.env?.EAS_BUILD === 'true') {
    
        // We're in the EAS_BUILD container.
        appConfig = require('./src/build/current-config/app.json');
    
      } else if (process?.env?.COMMON_EXPO_PATH) {
    
        // we're running in a local dev environment
        appConfig = {
          APP_DISPLAY_NAME: process.env?.APP_DISPLAY_NAME,
          APP_INTERNAL_NAME: process.env?.APP_INTERNAL_NAME,
          DEEP_LINK_SCHEME: process.env?.DEEP_LINK_SCHEME,
          FIREBASE_PROJECT_ID: process.env?.FIREBASE_PROJECT_ID,
          GOOGLE_MAPS_KEY_ANDROID: process.env?.GOOGLE_MAPS_KEY_ANDROID,
          GOOGLE_MAPS_KEY_IOS: process.env?.GOOGLE_MAPS_KEY_IOS,
          LABEL_CLAZZ_ACT: process.env?.LABEL_CLAZZ_ACT,
          LABEL_CLAZZ_ACTS: process.env?.LABEL_CLAZZ_ACTS,
          PROJ_SHORT_NAME: process.env?.PROJ_SHORT_NAME,
          SENTRY_ORG: process.env?.SENTRY_ORG,
          SENTRY_PROJECT: process.env?.SENTRY_PROJECT,
          SPLASH_BACKGROUND_COLOR: process.env?.SPLASH_BACKGROUND_COLOR,
          EAS_PROJECT_ID: process.env?.EAS_PROJECT_ID,
        };
      }
      
      const expoConfig = calculateExpoConfigSettings(appConfig);
    
      // return the app configuration (instead of `app.json`):
      return {...config, ...expoConfig};
    };
    
    1. The settings you show for your app.json are for the React-Native configuration (that involves other steps). But since you are using Expo I would encourage you to look at the Expo configuration steps:

    enter image description here

    Login or Signup to reply.
  1. I have the same issues. I follow the docs for expo and I get:

    No 'iosAppId' was provided. The native Google Mobile Ads SDK will crash on iOS without it.
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search