'"Task: react-native-admob: compileDebugJavaWithJavac FAILED" is displayed by react-native-admob
I implemented a video ad using react-native-admob. When I built it this morning, the app that should have worked properly suddenly failed to build.
> Task :react-native-admob:compileDebugJavaWithJavac FAILED
Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.5/userguide/command_line_interface.html#sec:command_line_warnings
22 actionable tasks: 2 executed, 20 up-to-date
/prj/node_modules/react-native-admob/android/src/main/java/com/sbugert/rnadmob/RNAdMobInterstitialAdModule.java:20: error: cannot find symbol.
import com.google.android.gms.ads.InterstitialAd;
^
symbol: class InterstitialAd
location: package com.google.android.gms.ads
/prj/node_modules/react-native-admob/android/src/main/java/com/sbugert/rnadmob/RNAdMobInterstitialAdModule.java:36: error: cannot find symbol.
InterstitialAd mInterstitialAd;
^
symbol: class InterstitialAd
location: class RNAdMobInterstitialAdModule
The development environment is as follows.
- react:16.9.0
- react-native:0.61.5
- Gradle:3.5.4
- Android 10 emulator
- react-native-admob:2.0.0-beta.6
- Android Studio:4.1.1
I have tried the following.
- Add the following to app / build.gradle
configurations.all {
resolutionStrategy {
force "com.google.android.gms:play-services-basement:17.0.0"
force "com.google.android.gms:play-services-base:17.1.0"
force "com.google.android.gms:play-services-stats:17.0.0"
force "com.google.android.gms:play-services-gcm:17.0.0"
force "com.google.android.gms:play-services-ads:19.7.0"
}
}
- Change From com.google.android.gms:play-services-ads:19.1.0 to com.google.android.gms:play-services-ads:19.7.0
- Change from [email protected] to [email protected]
- gradlew cache clean
- node_modules delete and npm install
Please let me know if there is a solution.
Solution 1:[1]
You can solve this issue by replacing lines in node-modules/react-native-admob/android/build.gradle
replace ==> implementation 'com.google.android.gms:play-services-ads:+.'
With ==>. implementation 'com.google.android.gms:play-services-ads:19.8.0'
Solution 2:[2]
Here's how I solved it.
- Create a patch file with the following command
npx patch-package react-native-admob --exclude
2.Move to the directory where build.gradle is located, create the files before and after modification, and execute the following command.
diff -up build.gradle build2.gradle
?build2.gradle is the temporary file name after the change.
3.Since the difference appears in 2, paste it into the patch file created in 1. Delete all the code of the existing patch file created in 1.
4.Execute the following command to apply the created patch file.
npm run patch-package && cp webrtclibs/android/* node_modules/react-native-webrtc/android/libs/
5.build
I would be very happy if it helps someone.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Muhammad Haidar |
Solution 2 | pooh |