简体   繁体   中英

react-native-google-mobile-ads with expo 47 crashes on launch with eas build

I have a managed app written in react-native with Expo SDK 47. I'm trying to add google ads to it.

According to the docs the expo-ads-admob was removed in SDK 46 and recommends react-native-google-mobile-ads . It will not work with Expo Go or the old expo build so I do a development build and use expo-dev-client .

When I build the app using eas build --profile development --platform ios --clear-cache the standalone app builds with no errors and I'm able to download and install the app on my phone.

When I launch the app from my phone it immediately crashes.

I think it's pretty known that if you don't have the "react-native-google-mobile-ads" key in place the app will crash on load. I actually tried to build the app without this key in place and it would fail to build saying that "ios_app_id" was required.

{
    "expo:" {
        ...
    },
    "react-native-google-mobile-ads": {
        "android_app_id": "ca-app-pub-xxxxxxxxxx/xxxxxx",
        "ios_app_id": "ca-app-pub-xxxxxxx/xxxxxxx"
    }

}

I have it setup exactly as instructed by the docs (can provide more code references if needed)

When I npm uninstall react-native-google-mobile-ads , comment out the code that uses the library, then rebuild the app with eas, the app will launch fine and everything works.

I'm having a hard time finding logs on the iPhone that mean anything to me.

How can I build with EAS and have the app not crash on me on the splash screen?

After spending way too much time on this, I found that the app will crash if you set the app ids to "bad" ids.

{
    "expo:" {
        ...
    },
    "react-native-google-mobile-ads": {
        "android_app_id": "ca-app-pub-xxxxxxxxxx/xxxxxxTHESEWEREBAD",
        "ios_app_id": "ca-app-pub-xxxxxxx/xxxxxxxTHESEWEREBAD"
    }

}

I generated fresh app_ids at apps.admob.com, set them in the react-native-google-mobile-ads key in app.json , rebuilt the app with eas and now the app loads just fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM