Solucionar error Attribute meta-data#com.google.android.gms.ads.DELAY_APP_MEASUREMENT_INIT@value con la libreria react-native-google-mobile-ads en React Native y Expo

Tiempo de lectura: < 1 minuto

Voy a enseñarte cómo solucionar el error:

[stderr] /home/expo/workingdir/build/android/app/src/debug/AndroidManifest.xml:21:85-105 Error:

[stderr] 	Attribute meta-data#com.google.android.gms.ads.DELAY_APP_MEASUREMENT_INIT@value value=(true) from AndroidManifest.xml:21: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:21:5-107 to override.

> Task :react-native-screens:parseDebugLocalResources

> Task :react-native-share:compileDebugLibraryResources

> Task :react-native-safe-area-context:generateDebugRFile

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.5.1/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.

351 actionable tasks: 351 executed

[stderr] FAILURE: Build completed with 2 failures.

[stderr] 1: Task failed with an exception.

[stderr] -----------

[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:21: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:21:5-107 to override.

Este error está asociado a la librería de com.google.android.gms.ads.

Para solucionarlo tenemos que ir a nuestro AndroidManifest.xml generado, buscar esta línea:

    <meta-data android:name="com.google.android.gms.ads.DELAY_APP_MEASUREMENT_INIT" android:value="true"/>

Y cambiarla a false:

    <meta-data android:name="com.google.android.gms.ads.DELAY_APP_MEASUREMENT_INIT" android:value="false"/>

Otra forma de solucionarlo es ir a nuestro archivo app.json y añadir esto:

 "react-native-google-mobile-ads": { 
"android_app_id": "xxxxxxxxxxxx", 
"ios_app_id": "xxxxxxxxxxxxxxx", 
"delay_app_measurement_init": true 
} 

Deja un comentario