在`react-native-admob`中出现错误,有人可以帮忙吗?

huangapple go评论85阅读模式
英文:

Error in react-native-admob, Can someone help me?

问题

我正在尝试将 AdMob 添加到我的项目中,但安装后,我的项目无法在我的手机上安装,有人知道可能是什么原因吗?

以下是错误信息:

配置项目:react-native-admob
警告:配置“编译”已过时,已替换为“实现”和“API”。
它将很快被移除。有关更多信息,请参见:http://d.android.com/r/tools/update-dependency-configurations.html
警告:忽略指定的Android SDK构建工具版本(23.0.1),因为它低于最低支持版本(28.0.3)> 解析:react-native-screens:debugCompileClasspath的依赖关系
对于Android Gradle插件3.5.3。
将使用Android SDK构建工具28.0.3。
要消除此警告,请从您的build.gradle文件中删除“buildToolsVersion'23.0.1'”,因为每个Android Gradle插件版本现在都具有构建工具的默认版本。

任务:react-native-gesture-handler:compileDebugJavaWithJavac

任务:react-native-reanimated:compileDebugJavaWithJavac

任务:react-native-admob:compileDebugJavaWithJavac FAILED

此构建中使用了已弃用的Gradle功能,因此与Gradle 7.0不兼容。
使用“--warning-mode all”显示各个已弃用警告。
请参见https://docs.gradle.org/6.2/userguide/command_line_interface.html#sec:command_line_warnings
40个可操作任务:38个已执行,2个最新
注意:某些输入文件使用或覆盖了已弃用的API。
注意:重新编译以获取有关详细信息的-Xlint:deprecation。
注意:某些输入文件使用不经过检查或不安全的操作。
注意:重新编译以获取有关详细信息的-Xlint:unchecked。
注意:C:\ Users \ 55419 \ Desktop \ MyApp2 \ node_modules \ react-native-reanimated \ android \ src \ main \ java \ com \ swmansion \ reanimated \ NodesMana
ger.java使用或覆盖了已弃用的API。
注意:重新编译以获取有关详细信息的-Xlint:deprecation。
注意:C:\ Users \ 55419 \ Desktop \ MyApp2 \ node_modules \ react-native-reanimated \ android \ src \ main \ java \ com \ swmansion \ reanimated \ NodesMana
ger.java使用不经过检查或不安全的操作。
注意:重新编译以获取有关详细信息的-Xlint:unchecked。
C:\ Users \ 55419 \ Desktop \ MyApp2 \ node_modules \ react-native-admob \ android \ src \ main \ java \ com \ sbugert \ rnadmob \ RNAdMobRewardedVideoAdMod
ule.java:20:错误:RNAdMobRewardedVideoAdModule不是抽象的,并且没有重写RewardedVideoAdListener中的抽象方法onRewardedVideoCompleted()
在RewardedVideoAdListener
public class RNAdMobRewardedVideoAdModule extends ReactContextBaseJavaModule implements RewardedVideoAdListener {
^
注意:某些输入文件使用或覆盖了已弃用的API。
注意:重新编译以获取有关详细信息的-Xlint:deprecation。
1个错误

构建失败。

*出了什么问题:
任务':react-native-admob:compileDebugJavaWithJavac'的执行失败。
>编译失败;有关详细信息,请参见编译器错误输出。

  • 尝试:
    使用--stacktrace选项运行以获取堆栈跟踪。使用--info或--debug选项运行以获取更多日志输出。使用--scan以获取完整见解。

  • 获取更多帮助,请访问https://help.gradle.org

在22秒内构建失败。

错误:未能安装应用程序。确保已设置Android开发环境:https://reactnative.dev/docs/envi
ronment-setup。使用--verbose标志运行CLI以获取更多详细信息。
错误:命令失败:gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
注意:某些输入文件使用或覆盖了已弃用的API。
错误:命令以退出代码1失败。
信息,请访问https://yarnpkg.com/en/docs/cli/run,以获取有关此命令的文档。

英文:

I'm trying to add admob to my project, but when installed, my project can't install on my phone, does anyone know what it might be?

error bellow

> Configure project :react-native-admob
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed soon. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
WARNING: The specified Android SDK Build Tools version (23.0.1) is ignored, as it is below the minimum supported version (28.0.3)> Resolve dependencies of :react-native-screens:debugCompileClasspath
for Android Gradle Plugin 3.5.3.
Android SDK Build Tools 28.0.3 will be used.
To suppress this warning, remove "buildToolsVersion '23.0.1'" from your build.gradle file, as each version of the Android Gradle
Plugin now has a default version of the build tools.

> Task :react-native-gesture-handler:compileDebugJavaWithJavac

> Task :react-native-reanimated:compileDebugJavaWithJavac

> Task :react-native-admob:compileDebugJavaWithJavac FAILED

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.2/userguide/command_line_interface.html#sec:command_line_warnings
40 actionable tasks: 38 executed, 2 up-to-date
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: C:\Users\55419\Desktop\MyApp2\node_modules\react-native-reanimated\android\src\main\java\com\swmansion\reanimated\NodesMana
ger.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:\Users\55419\Desktop\MyApp2\node_modules\react-native-reanimated\android\src\main\java\com\swmansion\reanimated\NodesMana
ger.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
C:\Users\55419\Desktop\MyApp2\node_modules\react-native-admob\android\src\main\java\com\sbugert\rnadmob\RNAdMobRewardedVideoAdMod
ule.java:20: error: RNAdMobRewardedVideoAdModule is not abstract and does not override abstract method onRewardedVideoCompleted()
in RewardedVideoAdListener
public class RNAdMobRewardedVideoAdModule extends ReactContextBaseJavaModule implements RewardedVideoAdListener {
^
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 error

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':react-native-admob:compileDebugJavaWithJavac'.
    > Compilation failed; see the compiler error output for details.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to
    get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 22s

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/envi
ronment-setup. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
Note: Some input files use or override a deprecated API.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

答案1

得分: 1

在 node-modules/react-native-admob/android/build.gradle 中,

将 ====> implementation 'com.google.android.gms:play-services-ads:+.'
替换为 ====> implementation 'com.google.android.gms:play-services-ads:19.8.0'

希望这能解决你的问题。

英文:

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'

Hope this will solve your issue

答案2

得分: 0

安装beta版本替代...

yarn add react-native-admob@next

不要忘记删除你的node-modules文件夹,以及清理你的构建文件夹 作为预防措施

英文:

Install the beta version instead...

yarn add react-native-admob@next

Don't forget to delete your node-modules folder, and clean your build folder as a precaution

huangapple
  • 本文由 发表于 2020年9月3日 03:42:46
  • 转载请务必保留本文链接:https://go.coder-hub.com/63712559.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定