在 React Native Android 中未指定 compileSdkVersion 错误

新手上路,请多包涵

当我尝试在我的 React Native 项目中构建 Android 应用程序时出现构建错误。

当我运行 react-native run-android 时,它说:

 > Configure project :react-native-os
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':react-native-os'.
> compileSdkVersion is not specified.

在 Android Studio 中,我可以看到它说了同样的话: Cause: compileSdkVersion is not specified.

所以我在 Android Studio 中编辑了 build.gradle(Module: app) 文件,但问题仍然存在,并且错误消息没有改变。

 android {
//    compileSdkVersion rootProject.ext.compileSdkVersion
    compileSdkVersion 28
    buildToolsVersion "28.0.3"
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

我在其他类似 线程中尝试了解决方案,但没有任何效果。有谁知道这里有什么问题?

原文由 sflow 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 1.4k
1 个回答

我也遇到了同样的问题:

1-在终端运行 npm i @react-native-firebase/app

2-按照 以下步骤 将 firebase 添加到 android 平台。

原文由 Amr Abdalrahman 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题