如何在React Native项目中指定minSdkVersion

时间:2018-07-24 16:09:56

标签: react-native create-react-native-app android-min-sdk

我已经使用create-react-native-app

创建了react native项目

我可以看到sdkVersion中有一个app.json属性,但是我想为该应用程序指定minSdkVersion

如何在React Native项目中指定minSdkVersion

3 个答案:

答案 0 :(得分:2)

You can change it from app/build.gradle directly Open the project go to the android/app folder and open build.gradle file. In this you can find

   defaultConfig {
    applicationId "PACKAGE_ID"
    minSdkVersion 16
    targetSdkVersion 27
    versionCode 1
    versionName "1.0"
    multiDexEnabled true
    ndk {
        abiFilters "armeabi-v7a", "x86"
    }
}

change this minSdkVersion 16 according to your requirement

答案 1 :(得分:1)

我在android \ build.gradle文件中具有以下设置...

buildscript {
    ext {
        supportLibVersion = "28.0.0"
        buildToolsVersion = "28.0.3"
        minSdkVersion = 23
        compileSdkVersion = 28
        targetSdkVersion = 28
    }
}

答案 2 :(得分:0)

您可能想注意到,本机的lib / package / module(根据需要)将minSdkVersion设置为16。您可以在他们的官方build.gradle文件中看到它:

android {
    compileSdkVersion 28

    ...

    defaultConfig {
        minSdkVersion(16)
        targetSdkVersion(28)
        versionCode(1)
        versionName("1.0")
    }

    ...
}

https://github.com/facebook/react-native/blob/7a72c35a20a18c19bf6ab883cb2c53a85bd4c5c0/ReactAndroid/build.gradle#L356

通过将minSdkVersion设置为16,react-native使用至少由KitKat版本本地支持的Android API。

This section provides data about the relative number of devices running a given version of the Android platform.

您可能会在这里看到官方的Platform Version Dashboard: https://developer.android.com/about/dashboards/index.html