首页 > 解决方案 > 在 Android 模拟器上运行 react-native 项目不起作用

问题描述

因为我想在我的应用程序上使用蓝牙,所以我下载并链接了 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 项目?

标签: androidreact-nativecmdsdkandroid-gradle-plugin

解决方案


将 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"
    }

}

推荐阅读