Skip to content

Commit fe0f4f2

Browse files
DoctorJohndylancom
authored andcommitted
fix: hotfix building without an app.json file
1 parent 1e52535 commit fe0f4f2

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

android/build.gradle

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,29 +74,28 @@ project.ext {
7474

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

77-
def isManagedExpoProject = !rootProject.file("android").exists() && !rootProject.file("ios").exists()
7877
def appJSONGoogleMobileAdsAppIDString = ""
7978
def appJSONGoogleMobileAdsDelayAppMeasurementInitBool = false
8079
def appJSONGoogleMobileAdsOptimizeInitializationBool = true
8180
def appJSONGoogleMobileAdsOptimizeAdLoadingBool = true
8281

83-
if (rootProject.ext.has("googleMobileAdsJson")) {
82+
if (rootProject.ext.has("googleMobileAdsJson") && rootProject.ext.googleMobileAdsJson) {
8483
appJSONGoogleMobileAdsAppIDString = rootProject.ext.googleMobileAdsJson.getStringValue("android_app_id", "")
8584
appJSONGoogleMobileAdsDelayAppMeasurementInitBool = rootProject.ext.googleMobileAdsJson.isFlagEnabled("delay_app_measurement_init", false)
8685
appJSONGoogleMobileAdsOptimizeInitializationBool = rootProject.ext.googleMobileAdsJson.isFlagEnabled("optimize_initialization", true)
8786
appJSONGoogleMobileAdsOptimizeAdLoadingBool = rootProject.ext.googleMobileAdsJson.isFlagEnabled("optimize_ad_loading", true)
8887
}
8988

90-
if (!appJSONGoogleMobileAdsAppIDString && !isManagedExpoProject) {
89+
if (!appJSONGoogleMobileAdsAppIDString) {
9190
println "\n\n\n"
9291
println "**************************************************************************************************************"
9392
println "\n\n\n"
94-
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."
95-
println " No android_app_id property was found in this location. The native Google Mobile Ads SDK will crash on startup without it."
93+
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."
94+
println " No android_app_id property was found in this location. The native Google Mobile Ads SDK will crash on startup without it."
95+
println " You can safely ignore this warning if you are using our Expo config plugin."
9696
println "\n\n\n"
9797
println "**************************************************************************************************************"
9898
println "\n\n\n"
99-
System.exit(1)
10099
}
101100

102101
android {

ios_config.sh

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,6 @@ while true; do
8888
_CURRENT_LOOKUPS=$((_CURRENT_LOOKUPS+1))
8989
done
9090

91-
# Bail out if project is a managed Expo project:
92-
if [[ ! -d "${PROJECT_DIR}/ios" ]] && [[ ! -d "${PROJECT_DIR}/android" ]]; then
93-
echo "info: Project does not contain an ios or android folder, assume it's a managed Expo project using our Expo Config Plugin."
94-
exit 0
95-
fi
96-
9791
if [[ ${_SEARCH_RESULT} ]]; then
9892
_JSON_OUTPUT_RAW=$(cat "${_SEARCH_RESULT}")
9993
_RN_ROOT_EXISTS=$(ruby -KU -e "require 'rubygems';require 'json'; output=JSON.parse('$_JSON_OUTPUT_RAW'); puts output[$_JSON_ROOT]" || echo '')
@@ -169,8 +163,9 @@ if ! [[ -f "${_TARGET_PLIST}" ]]; then
169163
fi
170164

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

176171
for plist in "${_TARGET_PLIST}" "${_DSYM_PLIST}" ; do

0 commit comments

Comments
 (0)