FAILURE: Build completed with 2 failures.
1: Task failed with an exception.
* Where:
Build file '/home/expo/workingdir/build/node_modules/react-native-google-mobile-ads/android/build.gradle' line: 75
* What went wrong:
A problem occurred evaluating project ':react-native-google-mobile-ads'.
> Cannot get property 'googleMobileAdsJson' on extra properties extension as it does not exist
2: Task failed with an exception.
* What went wrong:
A problem occurred configuring project ':react-native-google-mobile-ads'.
> compileSdkVersion is not specified. Please add it to build.gradle
What am I missing? Where did you see my code
Hi @anasbouziane,
In your project, I do not see that react-native-google-mobile-ads
library is set up correctly. As per their documentation here the react-native-google-mobile-ads
object has to go outside the expo
in app.json file. For example:
{
"expo": {
// ...
},
"react-native-google-mobile-ads": {
"android_app_id": "ca-app-pub-xxxxxxxx~xxxxxxxx",
"ios_app_id": "ca-app-pub-xxxxxxxx~xxxxxxxx"
}
}
Other issues in your project configuration are:
- There is
expo-ads-admob
installed and specified under package.json >"dependencies"
. Iâd suggest remove this since this package has been deprecated and removed from SDK 46 and above. Your project is using SDK 47. - Also, your project has another issue such as using React Native version 0.70.6 installed. SDK 47 is compatible with 0.70.5. This can be checked and resolved by running
expo-cli doctor
command locally. Fixing these dependencies issues, following instructions for setting upreact-native-google-mobile-ads
library, and then re-running the build should fix these issues.
Yes I see
Thanks wodin
@amanhimself
âexpoâ: {
// âŚ
},
âreact-native-google-mobile-adsâ: {
âandroid_app_idâ: âca-app-pub-xxxxxxxx~xxxxxxxxâ,
âios_app_idâ: âca-app-pub-xxxxxxxx~xxxxxxxxâ
},
This is my code, I donât see any difference
I removed the package you mentioned âexpo-ads-admobâ.
And when I try running the âexpo-cli doctor commandâ it gives an error
(The expected package.json path: C:.âŚ\command\package.json does not exist)
Is this path in any way related to your project?
(Maybe a stupid question but did you run it inside your project directory?)
No , but I added the command word the the command lol,
It worked well this time âexpo-cli doctorâ and it suggested this :
expo doctor --fix-dependencies
Some dependencies are incompatible with the installed expo package version:
- react-native - expected version: 0.70.5 - actual version installed: 0.70.6
This command is being executed with the global Expo CLI. Learn more: The New Expo CLI. In Expo SDK 46 we introduced a new⌠| by Evan Bacon | Exposition
To use the local CLI instead (recommended in SDK 46 and higher), run:
Some dependencies are incompatible with the installed expo package version:
- react-native - expected version: 0.70.5 - actual version installed: 0.70.6
Your project may not work correctly until you install the correct versions of the packages.
To install the correct versions of these packages, please run: expo doctor --fix-dependencies,
or install individual packages by running expo install [package-name âŚ]
Error: Problem validating fields in app.json. Learn more: Configure with app.json/app.config.js - Expo Documentation
⢠should NOT have additional property âreact-native-google-mobile-adsâ.
And when I run : expo doctor --fix-dependencies
Some dependencies are incompatible with the installed expo package version:
- react-native - expected version: 0.70.5 - actual version installed: 0.70.6
This command is being executed with the global Expo CLI. Learn more: âŚ
To use the local CLI instead (recommended in SDK 46 and higher), run:
âş npx expo install
Installing 1 SDK 47.0.0 compatible native module using npm.
npm install
added 4 packages, changed 7 packages, and audited 1207 packages in 47s
54 packages are looking for funding
run npm fund
for details
5 high severity vulnerabilities
To address all issues (including breaking changes), run:
npm audit fix --force
Run npm audit
for details.
Error: Problem validating fields in app.json. Learn more: âŚ
** ⢠should NOT have additional property âreact-native-google-mobile-adsâ.
Thatâs quite confusing
Of course in general you should use npx expo ...
instead of expo-cli ...
, but for upgrade
or doctor
you should indeed use expo-cli
The complaint about invalid fields in app.json
is probably just because the Expo tools arenât expecting non-expo stuff in app.json
. Not sure if itâs normal with react-native-google-mobile-ads
Thanks a lot for your time Michael.
When I am looking at your latest build, I see the "react-native-google-mobile-ads"
part of "expo"
block configuration in app.json. As per their docs, this "react-native-google-mobile-ads"
block needs to be outside of the block "expo"
.
Here is an example configuration of how app.json will look like:
{
"expo": { //--> expo blocks start here
"name": "rnadmob-test",
"slug": "rnadmob-test",
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/icon.png",
"userInterfaceStyle": "light",
"splash": {
"image": "./assets/splash.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"updates": {
"fallbackToCacheTimeout": 0
},
"assetBundlePatterns": ["**/*"],
"ios": {
"supportsTablet": true
},
"android": {
"adaptiveIcon": {
"foregroundImage": "./assets/adaptive-icon.png",
"backgroundColor": "#FFFFFF"
},
"package": "com.amanhimself.admobstest"
},
"web": {
"favicon": "./assets/favicon.png"
},
"extra": {
"eas": {
"projectId": "910c5ec6-6bdf-4476-9b2e-a216c4f14248"
}
}
}, //--> expo blocks ends here
// then the mobile ads library config is added =======================
"react-native-google-mobile-ads": {
"android_app_id": "ca-app-pub-1671297437112106~3920968130",
"ios_app_id": "ca-app-pub-1671297437112106~3920968130"
}
}
Could also be this is why you are getting the invalid app.json error as you shared:
Invariant Violation: Your JavaScript code tried to access a native module that doesnât exist.
A frequent cause of the error is that the application entry file path is incorrect. This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.
There is always errors I donât know why , I did all the things you mentioned
Are you getting the error when you are running the build on the device/emulator? Also, which command you are using to start the development server in the development build?
Just to be clear, you will not be able to run this in Expo Go. You will need to run it in a development build (a.k.a. dev client) which is basically like a custom version of Expo Go that has your dependencies compiled in.
-
I have created another project and installed the
react-native-google mobile-ads
and added the block inApp.json
as you mentioned. -
The command I am using to start is
'npx expo start --tunnel'
and then I scan the code from the Expo mobile app from my âiPhone 7â , but suddenly nothing appears except that default splash screen. -
Also successfully intalled
expo-dev-client
. -
when I run
'npm install -g eas-cli'
it gives this :
changed 351 packages, and audited 352 packages in 10s*
35 packages are looking for funding*
runnpm fund
for details*2 high severity vulnerabilities*
Some issues need review, and may require choosing*
a different dependency.
-
I successfully logged in using eas login.
-
I successfully exucuted also
eas build:configure
:
đĄ The following process will configure your iOS and/or Android project to be compatible with EAS Build. These changes only
apply to your local project files and you can safely revert them at any time.
â Which platforms would you like to configure for EAS Build? Âť Android
đ Your project is ready to build.
- Run eas build when you are ready to create your first build.
- Once the build is completed, run eas submit to upload the app to app stores.
- Learn more about other capabilities of EAS Build: https://docs.expo.dev/build/introduction
And my code is as simple as that :
import { StatusBar } from 'expo-status-bar';
import { StyleSheet, Text, View } from 'react-native';
import {
// AppOpenAd,
// InterstitialAd,
// RewardedAd,
BannerAd,
TestIds,
BannerAdSize,
} from "react-native-google-mobile-ads";
export default function App() {
return (
<SafeAreaView style={styles.container}>
<View>
<Text>Open up App.js to start working on your app!</Text>
<StatusBar style="auto" />
</View>
<BannerAd
unitId={TestIds.BANNER}
size={BannerAdSize.LARGE_BANNER}
requestOptions={{
requestNonPersonalizedAdsOnly:true
}}
/>
</SafeAreaView>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
After running npx expo start --tunnel ,this is the error message :
`A frequent cause of the error is that the application entry file path is incorrect. This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.
eas build --platform android
â Using remote Android credentials (Expo server)
â Using Keystore from configuration: Build Credentials YmmLiOHo8q (default)
Compressing project files and uploading to EAS Build. Learn more: https://expo.fyi/eas-build-archive
â Uploaded to EAS 3s
Build details: https://expo.dev/accounts/anasbouziane/projects/adstest/builds/4e8babe7-b4da-4ccd-8233-af6e4e149bed
Waiting for build to complete. You can press Ctrl+C to exit.
â Build finished
đ¤ Android app:
https://expo.dev/artifacts/eas/axVukmkyRgwkfSkX.aab
The Expo Go mobile app? Or the development build?
You should create a new development build after installing this.
Yes, thatâs unfortunate, but misleading.
https://twitter.com/dan_abramov/status/1412376404738686984
https://twitter.com/dan_abramov/status/1412776197528997894
That is a production build. Add --profile development
to create a development APK