React Native : Change targeted sdk version for play store upload - react-native

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.

Related

The Android Gradle plugin supports only kotlin-android-extensions Gradle plugin version 1.6.20 and higher How to fix this?

dependencies": { "react": "17.0.2", "react-native":"0.70.1", "react-native-payumoney": "^1.0.2" },
Below is a image
my build.gradle file:
buildscript { ext{
kotlinVersion = "1.7.0"
android_plugin_version = '3.2.1'
minSdkVersion = 21
compileSdkVersion = 31
targetSdkVersion = 31
}
gradle-wrapper.properties
distributionUrl=https://services.gradle.org/distributions/gradle-7.5.1-all.zip.
Pls, help me i try to resolve last few days,but still isn't working.
I also try to change different kotlineVersion but isn't work.

React Naitve Android error compileSdkVersion is not specified. Please add it to build.gradle

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

Execution failed for task ':realm:stripDebugDebugSymbols'

After installing realm in react native and setting up all necessary things console give me this error after starting project (npm run android);
Execution failed for task ':realm:stripDebugDebugSymbols'. NDK at C:\Users\123\AppData\Local\Android\Sdk\ndk\21.4.7075529 did not have a source.properties file.
I check ndk in android studio (after opening project in it) in Android SDK --> SDK tools sections, the ndk already installed. I also change the ndk version (one by one) in android/build.gradle according to some other stackoverflow solutions but didn't work. Below is android/build.gradle code;
buildscript {
ext {
buildToolsVersion = "30.0.2"
minSdkVersion = 21
compileSdkVersion = 30
targetSdkVersion = 30
ndkVersion = "21.4.7075529"//"25.1.8937393"//"21.1.6528147"
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:4.2.2")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
This is a android studio screen shot of sdk tools SDK tools

How to specify the minSdkVersion in react native project

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

Android Studio 2.2 update cause DefaultManifestParser cannot be resolve

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'
}