react-native-admob 显示“任务:react-native-admob:compileDebugJavaWithJavac FAILED”

poo*_*ooh 3 android admob react-native

我使用react-native-admob 实现了一个视频广告。\n当我今天早上构建它时,本应正常运行的应用程序突然无法构建。

\n
> Task :react-native-admob:compileDebugJavaWithJavac FAILED\n\nDeprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.\nUse '--warning-mode all' to show the individual deprecation warnings.\nSee https://docs.gradle.org/5.5/userguide/command_line_interface.html#sec:command_line_warnings\n22 actionable tasks: 2 executed, 20 up-to-date\n/prj/node_modules/react-native-admob/android/src/main/java/com/sbugert/rnadmob/RNAdMobInterstitialAdModule.java:20: error: cannot find symbol.\nimport com.google.android.gms.ads.InterstitialAd;\n                                 ^\n  symbol:   class InterstitialAd\n  location: package com.google.android.gms.ads\n/prj/node_modules/react-native-admob/android/src/main/java/com/sbugert/rnadmob/RNAdMobInterstitialAdModule.java:36: error: cannot find symbol.\n    InterstitialAd mInterstitialAd;\n    ^\n  symbol:   class InterstitialAd\n  location: class RNAdMobInterstitialAdModule\n\n
Run Code Online (Sandbox Code Playgroud)\n

开发环境如下。

\n
    \n
  • 反应\xef\xbc\x9a16.9.0
  • \n
  • 反应本机\xef\xbc\x9a0.61.5
  • \n
  • 等级:3.5.4
  • \n
  • 安卓10模拟器
  • \n
  • 反应本机admob:2.0.0-beta.6
  • \n
  • 安卓工作室:4.1.1
  • \n
\n

我已经尝试过以下方法。

\n
    \n
  • 将以下内容添加到app/build.gradle
  • \n
\n
configurations.all {\n    resolutionStrategy {\n        force "com.google.android.gms:play-services-basement:17.0.0"\n        force "com.google.android.gms:play-services-base:17.1.0"\n        force "com.google.android.gms:play-services-stats:17.0.0"\n        force "com.google.android.gms:play-services-gcm:17.0.0"\n        force "com.google.android.gms:play-services-ads:19.7.0"\n    }\n}\n
Run Code Online (Sandbox Code Playgroud)\n
    \n
  • 从 com.google.android.gms:play-services-ads:19.1.0 更改为 com.google.android.gms:play-services-ads:19.7.0
  • \n
  • 从react-native-admob@2.0.0-beta.6更改为react-native-admob@1.3.2
  • \n
  • gradlew 缓存清理
  • \n
  • node_modules 删除并 npm install
  • \n
\n

如果有解决方案,请告诉我。

\n

Muh*_*dar 11

您可以通过替换 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'
Run Code Online (Sandbox Code Playgroud)