Skip to content

Commit

Permalink
fix: hotfix building without an app.json file
Browse files Browse the repository at this point in the history
  • Loading branch information
DoctorJohn authored and dylancom committed Aug 9, 2024
1 parent 1e52535 commit fe0f4f2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
11 changes: 5 additions & 6 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -74,29 +74,28 @@ project.ext {

apply from: file("./app-json.gradle")

def isManagedExpoProject = !rootProject.file("android").exists() && !rootProject.file("ios").exists()
def appJSONGoogleMobileAdsAppIDString = ""
def appJSONGoogleMobileAdsDelayAppMeasurementInitBool = false
def appJSONGoogleMobileAdsOptimizeInitializationBool = true
def appJSONGoogleMobileAdsOptimizeAdLoadingBool = true

if (rootProject.ext.has("googleMobileAdsJson")) {
if (rootProject.ext.has("googleMobileAdsJson") && rootProject.ext.googleMobileAdsJson) {
appJSONGoogleMobileAdsAppIDString = rootProject.ext.googleMobileAdsJson.getStringValue("android_app_id", "")
appJSONGoogleMobileAdsDelayAppMeasurementInitBool = rootProject.ext.googleMobileAdsJson.isFlagEnabled("delay_app_measurement_init", false)
appJSONGoogleMobileAdsOptimizeInitializationBool = rootProject.ext.googleMobileAdsJson.isFlagEnabled("optimize_initialization", true)
appJSONGoogleMobileAdsOptimizeAdLoadingBool = rootProject.ext.googleMobileAdsJson.isFlagEnabled("optimize_ad_loading", true)
}

if (!appJSONGoogleMobileAdsAppIDString && !isManagedExpoProject) {
if (!appJSONGoogleMobileAdsAppIDString) {
println "\n\n\n"
println "**************************************************************************************************************"
println "\n\n\n"
println "ERROR: react-native-google-mobile-ads requires an 'android_app_id' property inside a 'react-native-google-mobile-ads' key in your app.json."
println " No android_app_id property was found in this location. The native Google Mobile Ads SDK will crash on startup without it."
println "WARNING: react-native-google-mobile-ads requires an 'android_app_id' property inside a 'react-native-google-mobile-ads' key in your app.json."
println " No android_app_id property was found in this location. The native Google Mobile Ads SDK will crash on startup without it."
println " You can safely ignore this warning if you are using our Expo config plugin."
println "\n\n\n"
println "**************************************************************************************************************"
println "\n\n\n"
System.exit(1)
}

android {
Expand Down
11 changes: 3 additions & 8 deletions ios_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,6 @@ while true; do
_CURRENT_LOOKUPS=$((_CURRENT_LOOKUPS+1))
done

# Bail out if project is a managed Expo project:
if [[ ! -d "${PROJECT_DIR}/ios" ]] && [[ ! -d "${PROJECT_DIR}/android" ]]; then
echo "info: Project does not contain an ios or android folder, assume it's a managed Expo project using our Expo Config Plugin."
exit 0
fi

if [[ ${_SEARCH_RESULT} ]]; then
_JSON_OUTPUT_RAW=$(cat "${_SEARCH_RESULT}")
_RN_ROOT_EXISTS=$(ruby -KU -e "require 'rubygems';require 'json'; output=JSON.parse('$_JSON_OUTPUT_RAW'); puts output[$_JSON_ROOT]" || echo '')
Expand Down Expand Up @@ -169,8 +163,9 @@ if ! [[ -f "${_TARGET_PLIST}" ]]; then
fi

if ! [[ $_IOS_APP_ID ]]; then
echo "error: ios_app_id key not found in react-native-google-mobile-ads key in app.json. App will crash without it."
exit 1
echo "warning: ios_app_id key not found in react-native-google-mobile-ads key in app.json. App will crash without it."
echo " You can safely ignore this warning if you are using our Expo config plugin."
exit 0
fi

for plist in "${_TARGET_PLIST}" "${_DSYM_PLIST}" ; do
Expand Down

0 comments on commit fe0f4f2

Please sign in to comment.