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?
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
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
}
}
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.
You may see the official Platform Version Dashboard here:
https://developer.android.com/about/dashboards/index.html
Related
I am having build error
What went wrong:
A problem occurred configuring project ':app'.
compileSdkVersion is not specified. Please add it to build.gradle
build.gradle
googlePlayServicesVersion = "+"
firebaseMessagingVersion = "21.1.0"
buildToolsVersion = "29.0.3"
minSdkVersion = 21
compileSdkVersion = 30
targetSdkVersion = 30
app/build.gradle
compileSdkVersion rootProject.ext.compileSdkVersion
Ia m using React Native version 0.63.4 and gradle version 7
How do I fix this?
I tried online solutions nothing worked
I need to install my app in a Minix with Android 5.1 (API 22).
My build-graddle.app was initially:
compileSdk 32
defaultConfig {
applicationId "com.enterprise.appminix"
minSdk 25
targetSdk 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
And I changed to:
compileSdk 22
defaultConfig {
applicationId "com.enterprise.appminix"
minSdk 22
targetSdk 22
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
But can´t compile now.
How to configure android studio to build api 22 app
Could you help me?
I was trying to use this library https://github.com/MacKentoch/react-native-beacons-manager in my project but the app crashes exactly with the method startRangingBeaconsInRegion(region). I'm using React Native 0.62.5
My AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
My build.gradle
buildscript {
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion = "28.0.0"
}
}
Well I finally solve the problem trying this
https://github.com/MacKentoch/react-native-beacons-manager/issues/147#issuecomment-548567823
But for me doesn't work the fisrt step I just keep the 1.0.7 version in my project. I hope to help someone else :)
In Play Store I am trying to upload my app but I'm getting a warning i.e. mentioned below:
Target API level requirements from August 2018
Warning:
Your app currently targets API level 22 and must target at least API level 26 to ensure it is built on the latest APIs optimized for security and performance.
From August 2018, new apps must target at least Android 8.0 (API level 26).
From November 2018, app updates must target Android 8.0 (API level 26).
Open build.gradle under android/app/
find the android { } block
Change the following version to the below:
compileSdkVersion 27
buildToolsVersion "27.0.3"
minSdkVersion 16
targetSdkVersion 27
In the dependencies block, change the appcompat line to match the target version
compile "com.android.support:appcompat-v7:27.1.1"
In case your current android/app/build.gradle has lines which look like
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
You will have to edit the android/build.gradle to include
buildscript {
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 21
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion = "28.0.0"
}
...
}
Although I do not know where to get the latest versions.
It would be great if someone could edit this to include where to get the latest version numbers
From August 2021, API level should be 30 or above.
I have React Native app and my android/app/build.gradle looks like below
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
Changed the android/build.gradle to have below content which worked
buildscript {
ext {
buildToolsVersion = "30.0.2"
minSdkVersion = 21
compileSdkVersion = 30
targetSdkVersion = 30
ndkVersion = "20.1.5948944"
}
....
Just change targetVwersion to 26 in ./android/app/build.gradle
for the maven part, mentioned by #Bodhish, I needed to do it this way:
allprojects {
repositories {
mavenLocal()
jcenter()
maven {
url 'https://maven.google.com'
}
maven {
// All of React Native (JS, Obj-C sources, Android binaries)
// is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
}
}
with this piece added in addition to #albert's comment resolved for me.
Recently I updated android studio to android studio 2.2 and using gradle 2.14.1. However, com.android.builder.core.DefaultManifestParser cannot be resolve after the update. Below are the codes that I am using. Any recommend workaround to solve this issue? Thanks
defaultConfig {
def manifestParser = new DefaultManifestParser(android.sourceSets.main.manifest.srcFile)
applicationId = manifestParser.getPackage()
versionName = manifestParser.getVersionName()
versionCode manifestParser.getVersionCode()
minSdkVersion manifestParser.getMinSdkVersion()
targetSdkVersion manifestParser.getTargetSdkVersion()
multiDexEnabled true
}
My defaultConfig setting is similar to yours and it's successfully built,
defaultConfig {
def manifestFile = (File) android.sourceSets.main.manifest.srcFile
def manifestParser = new DefaultManifestParser(manifestFile)
//noinspection GroovyAssignabilityCheck
applicationId = manifestParser.getPackage()
minSdkVersion 18
targetSdkVersion 23
//noinspection GroovyAssignabilityCheck
versionName = manifestParser.getVersionName()
//noinspection GroovyAssignabilityCheck
versionCode = manifestParser.getVersionCode()
}
so I guess probably the required *.jar hasn't been successfully downloaded during the IDE update. Could you double check whether the file builder-2.2.0.jar exists under the IDE folder(e.g., C:\Program Files\Android\android-studio_2.2\gradle\m2repository\com\android\tools\build\builder\2.2.0). If it does exist, can do a further checking to make sure the file DefaultManifestParser.class is really inside folder \com\android\builder\core by extracting builder-2.2.0.jar.
If the above mentioned file and class do exist, can also try using import com.android.builder.core.DefaultManifestParser, however, it's a bit weird that we have to use this.
Just think of there is another thing to check is the Gradle plugin class path, it should be like this
classpath 'com.android.tools.build:gradle:2.2.0'
I have same trouble,and reback gradle version to 2.1.3 it is working
dependencies {
classpath 'com.android.tools.build:gradle:2.1.3'
}