【问题标题】:Running react-native project on Android emulator doesn't work在 Android 模拟器上运行 react-native 项目不起作用
【发布时间】:2019-04-26 10:52:08
【问题描述】:

因为我想在我的应用程序上使用蓝牙,所以我下载并链接了 react-native-ble-plx。 当我尝试 react-native run-Android 时出现以下错误:

Task :app:processDebugManifest FAILED
C:\Users\Aurelien\Desktop\Leroy-Somer\AMJE nativ\AMJE\android\app\src\debug\AndroidManifest.xml Error:
    uses-sdk:minSdkVersion 16 cannot be smaller than version 18 declared in library [:react-native-ble-plx] C:\Users\Aurelien\Desktop\Leroy-Somer\AMJE nativ\AMJE\node_modules\react-native-ble-plx\android\build\intermediates\library_manifest\debug\AndroidManifest.xml as the library might be using APIs not available in 16
    Suggestion: use a compatible library with a minSdk of at most 16,
            or increase this project's minSdk version to at least 18,
            or use tools:overrideLibrary="com.polidea.reactnativeble" to force usage (may lead to runtime failures)

我知道我有错误的 SDK 版本,但我不知道如何更新它

如何更新?

我必须在更新后创建一个新的 React Native 项目吗?

【问题讨论】:

    标签: android react-native cmd sdk android-gradle-plugin


    【解决方案1】:

    正如您在https://github.com/Polidea/react-native-ble-plx/blob/master/android/build.gradle 看到的那样,“react-native-ble-plx”的 min-sdk 为 18,但您的项目的 min-sdk 为 16。因此您没有资格使用该库。到目前为止,您可以做的最简单的事情是转到您的“project/android/app/build.gradle”文件并将您自己的 min-sdk 增加到 18

    【讨论】:

      【解决方案2】:

      将 app/build.gradle 中的最低 sdk 版本更新为。

      android {
          compileSdkVersion 28
      
          defaultConfig {
              applicationId "com.example.myapplication"
              minSdkVersion 18
              targetSdkVersion 28
              versionCode 1
              versionName "1.0"
              testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
          }
      
      }
      

      【讨论】:

        猜你喜欢
        • 2016-11-29
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-01-01
        • 2017-07-13
        相关资源
        最近更新 更多