13

I have created react native project using create-react-native-app

I can see that there is a sdkVersion property in app.json, but I want to specify minSdkVersion for the app.

How do I specify the minSdkVersion in react native project?

ofundefined
  • 2,692
  • 2
  • 18
  • 35
Vivek
  • 11,938
  • 19
  • 92
  • 127

3 Answers3

17

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

Jay Thummar
  • 2,281
  • 1
  • 14
  • 22
  • For newer versions of React Native it seems this answer is better: https://stackoverflow.com/a/58750145/5552415. Remember there are two build.gradle files. The one in android/app may have rootProject.ext.minSdkVersion instead of a number, so just go into the parent directory and change the minSdkVersion like in the other answer I suggested. – Ger Jun 02 '21 at 13:40
5

I have these settings in the android\build.gradle file as per below...

buildscript {
    ext {
        supportLibVersion = "28.0.0"
        buildToolsVersion = "28.0.3"
        minSdkVersion = 23
        compileSdkVersion = 28
        targetSdkVersion = 28
    }
}
Matt Booth
  • 1,723
  • 3
  • 13
  • 19
1

You might like to notice that react-native lib/package/module (as you wish) sets the minSdkVersion to 16. You can see it here on their official build.gradle file:

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

By setting minSdkVersion to 16, react-native uses Android API's natively supported by at least KitKat version.

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

You may see the official Platform Version Dashboard here: https://developer.android.com/about/dashboards/index.html

ofundefined
  • 2,692
  • 2
  • 18
  • 35