Am trying to use react-native-google-mobile-ads package but my EAS build always fail on both Ios and Android if the package is installed. but builds without issue if i remove the package. I have added both Ios and Android app id in app.josn as instructed but I still cant use React native google mobile ads. Please someone should help me with a working solution.
Expo SDK 48
IOS EAS Build Error:
❌ error: ios_app_id key not found in react-native-google-mobile-ads key in app.json. App will crash without it.
Run script build phase '[CP-User] Generate app.config for prebuilt Constants.manifest' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'EXConstants' from project 'Pods')
▸ ** ARCHIVE FAILED **
▸ The following build commands failed:
▸ PhaseScriptExecution [CP-User] [RNGoogleMobileAds] Configuration /Users/expo/Library/Developer/Xcode/DerivedData/Trupal-bncukuqtvgpwvbckuuqzbimfabiw/Build/Intermediates.noindex/ArchiveIntermediates/Trupal/IntermediateBuildFilesPath/Trupal.build/Debug-iphoneos/Trupal.build/Script-2075EEC1F9F6BBAA447280FF.sh (in target ‘Trupal’ from project ‘Trupal’)
▸ (1 failure)
Android EAS Build Error:
[stderr]
FAILURE: Build completed with 2 failures.
[stderr]
1: Task failed with an exception.
[stderr]
[stderr]
- Where:
[stderr] Build file ‘/home/expo/workingdir/build/node_modules/react-native-google-mobile-ads/android/build.gradle’ line: 75
[stderr] - What went wrong:
[stderr] A problem occurred evaluating project ‘:react-native-google-mobile-ads’.
[stderr]
Cannot get property ‘googleMobileAdsJson’ on extra properties extension as it does not exist
[stderr]
- Try:
[stderr]
Run with –stacktrace option to get the stack trace.
[stderr] Run with –info or –debug option to get more log output.
[stderr] Run with –scan to get full insights.
[stderr] ==============================================================================
[stderr] 2: Task failed with an exception.
[stderr]
[stderr]
- What went wrong:
[stderr] A problem occurred configuring project ‘:react-native-google-mobile-ads’.
[stderr]
compileSdkVersion is not specified. Please add it to build.gradle
[stderr]
- Try:
[stderr]
Run with –stacktrace option to get the stack trace.
[stderr] Run with –info or –debug option to get more log output.
Build to be successful
2
Answers
On error above it said "❌ error: ios_app_id key not found in react-native-google-mobile-ads key in app.json. App will crash without it." Are you sure already follow all the requirement config for the library? Please show app.json config?
Did you add googleServicesFile also?
admob key
googleServicesFile:
using react native and trying to install google ad mob, the issue was adding this line to app.json
if you are using expo to build your app in iOS, this config is not needed and only cause all kind of weird errors