react-native-google-mobile-ads android problem

I upgraded my sdk to 45. I was able to install and build react-native-google-mobile-ads on ios. But android fails. This error after development client build

stderr] 
/home/expo/workingdir/build/android/app/src/debug/AndroidManifest.xml:18:85-105 Error:
[stderr] 
	Attribute meta-data#com.google.android.gms.ads.DELAY_APP_MEASUREMENT_INIT@value value=(true) from AndroidManifest.xml:18:85-105
[stderr] 
	is also present at [:react-native-google-mobile-ads] AndroidManifest.xml:19:13-34 value=(false).
[stderr] 
	Suggestion: add 'tools:replace="android:value"' to <meta-data> element at AndroidManifest.xml:18:5-107 to override.
[stderr] 
FAILURE: Build failed with an exception.
[stderr] 
* What went wrong:
[stderr] 
Execution failed for task ':app:processDebugMainManifest'.
[stderr] 
> Manifest merger failed : Attribute meta-data#com.google.android.gms.ads.DELAY_APP_MEASUREMENT_INIT@value value=(true) from AndroidManifest.xml:18:85-105
[stderr] 
  	is also present at [:react-native-google-mobile-ads] AndroidManifest.xml:19:13-34 value=(false).
[stderr] 
  	Suggestion: add 'tools:replace="android:value"' to <meta-data> element at AndroidManifest.xml:18:5-107 to override.
[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] 
* Get more help at https://help.gradle.org
[stderr] 
BUILD FAILED in 5m 29s
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See https://docs.gradle.org/7.3.3/userguide/command_line_interface.html#sec:command_line_warnings
Execution optimizations have been disabled for 1 invalid unit(s) of work during this build to ensure correctness.
Please consult deprecation warnings for more details.
413 actionable tasks: 413 executed
Unable to list file systems to check whether they can be watched. The whole state of the virtual file system has been discarded. Reason: Could not query file systems: could not open mount file (errno 2: No such file or directory)
Error: Gradle build failed with unknown error. Please see logs for the "Run gradlew" phase.

Any help would be appreciated.

Hi @emrahc

I installed react-native-google-mobile-ads in a new SDK 45 app and added the app IDs to app.json. I was able to build an android dev client successfully.

Please post the full dependencies and devDependencies sections from package.json.
Also, try running expo doctor to see if it complains about anything.

Thanks for answer. Expo doctor found no problem
i have app ID’s in app.json
package.json

 "dependencies": {
    "@kanzitelli/if-component": "^0.3.0",
    "@react-native-async-storage/async-storage": "~1.17.3",
    "@react-native-community/masked-view": "^0.1.11",
    "@react-native-community/netinfo": "8.2.0",
    "@react-native-picker/picker": "2.4.0",
    "@react-navigation/bottom-tabs": "^6.0.9",
    "@react-navigation/native": "^6.0.6",
    "@react-navigation/native-stack": "^6.2.5",
    "@react-navigation/stack": "^6.0.11",
    "add": "^2.0.6",
    "crypto": "^1.0.1",
    "date-fns": "^2.28.0",
    "dayjs": "^1.11.0",
    "expo": "^45.0.0",
    "expo-analytics-amplitude": "~11.2.0",
    "expo-asset": "~8.5.0",
    "expo-camera": "~12.2.0",
    "expo-crypto": "~10.2.0",
    "expo-dev-client": "~1.0.0",
    "expo-device": "~4.2.0",
    "expo-face-detector": "~11.2.0",
    "expo-font": "~10.1.0",
    "expo-gl": "~11.3.0",
    "expo-image-crop": "^1.0.4",
    "expo-image-manipulator": "~10.3.1",
    "expo-image-picker": "~13.1.1",
    "expo-linear-gradient": "~11.3.0",
    "expo-linking": "~3.1.0",
    "expo-localization": "~13.0.0",
    "expo-notifications": "~0.15.4",
    "expo-permissions": "~13.2.0",
    "expo-secure-store": "~11.2.0",
    "expo-sharing": "~10.2.0",
    "expo-splash-screen": "~0.15.1",
    "expo-sqlite": "~10.2.0",
    "expo-status-bar": "~1.3.0",
    "expo-store-review": "~5.2.0",
    "expo-updates": "~0.13.2",
    "expo-web-browser": "~10.2.1",
    "formik": "^2.2.9",
    "i18n-js": "^3.8.0",
    "lodash": "^4.17.21",
    "lottie-react-native": "5.0.1",
    "mobx": "^6.3.12",
    "mobx-persist-store": "^1.0.4",
    "mobx-react": "^7.2.1",
    "no-scroll": "^2.1.1",
    "react": "17.0.2",
    "react-dom": "17.0.2",
    "react-native": "0.68.2",
    "react-native-animated-loader": "^0.0.9",
    "react-native-barcode-mask": "^1.2.4",
    "react-native-fast-image": "^8.5.11",
    "react-native-floating-label-input": "^1.3.13",
    "react-native-gesture-handler": "~2.2.1",
    "react-native-get-random-values": "~1.8.0",
    "react-native-google-mobile-ads": "^7.0.1",
    "react-native-icon-badge": "^1.1.3",
    "react-native-keyboard-aware-scroll-view": "^0.9.5",
    "react-native-mmkv": "^2.4.1",
    "react-native-modal": "^13.0.0",
    "react-native-purchases": "^4.5.1",
    "react-native-reanimated": "~2.8.0",
    "react-native-redash": "^16.2.3",
    "react-native-responsive-fontsize": "^0.5.1",
    "react-native-restart": "^0.0.24",
    "react-native-safe-area-context": "4.2.4",
    "react-native-screens": "~3.11.1",
    "react-native-star-rating": "^1.1.0",
    "react-native-status-bar-height": "^2.6.0",
    "react-native-svg": "12.3.0",
    "react-native-svg-animations": "^0.2.6",
    "react-native-ui-lib": "^6.7.0",
    "react-native-vision-camera": "^2.13.3",
    "react-native-web": "0.17.7",
    "react-native-webview": "11.18.1",
    "recoil": "^0.5.2",
    "recompose": "^0.30.0",
    "recyclerlistview": "^3.0.5",
    "rn-bounceable": "^1.1.0",
    "yup": "^0.32.11"
  },
  "devDependencies": {
    "@babel/core": "^7.12.9",
    "@expo/config-plugins": "^4.1.0",
    "@expo/webpack-config": "~0.16.21",
    "@react-native-community/eslint-config": "^3.0.1",
    "@types/i18n-js": "^3.8.2",
    "@types/lodash": "^4.14.178",
    "@types/react": "~17.0.21",
    "@types/react-dom": "~17.0.11",
    "@types/react-native": "~0.67.6",
    "@typescript-eslint/parser": "^5.9.0",
    "dotenv-cli": "^4.1.1",
    "prettier": "^2.4.1",
    "react-native-svg-transformer": "^1.0.0",
    "release-it": "^14.11.8",
    "typescript": "~4.3.5"
  }

I’ll try building with your dependencies. In the mean time, I have a question and a comment:

Not necessarily a problem, but any reason you have both expo-camera and react-native-vision-camera installed?

Unfortunately, expo doctor can’t catch everything :slight_smile:

From the MaskedView docs:

You can only have one of either @react-native-community/masked-view (deprecated) or @react-native-masked-view/masked-view installed in your project at any given time. React Navigation v6 and above requires @react-native-masked-view/masked-view, so you should use that package instead if you are using the latest version of React Navigation.

My test app built successfully with your dependencies.

Maybe try removing your package-lock.json / yarn.lock and node_modules and re-installing your dependencies. There might be something in the dependency tree that’s incompatible, but not picked up by expo doctor.

Also, could you post the "plugins" section of your app.json? Also, I see you have @expo/config-plugins as a devDependency. Does this mean you have a custom config plugin? If so, what does it do?

I was using two seperate camera packages for ios and android. I seperated ios and android. Removed expo-camera and face detector. Kept react native vision camera for android. Than adsmob package worked.

Thanks for help

1 Like