React-native: Android Target API Level 26 required in August 2018 #2

Created on 26 Feb 2018  路  11Comments  路  Source: facebook/react-native

Here we go again, since #17287 was closed.

Now I know that this isn't a real bug report. It is not even a real feature request. But I needed to post this somewhere and none of the other channels seemed appropriate.

On 19 December Google announced the following:

In the second half of 2018, Play will require that new apps and app updates target a recent Android API level. This will be required for new apps in August 2018, and for updates to existing apps in November 2018. This is to ensure apps are built on the latest APIs optimized for security and performance.

source: https://android-developers.googleblog.com/2017/12/improving-app-security-and-performance.html

More specifically:

  • August 2018: New apps required to target API level 26 (Android 8.0) or higher.
  • November 2018: Updates to existing apps required to target API level 26 or higher.
  • 2019 onwards: Each year the targetSdkVersion requirement will advance. Within one year following each Android dessert release, new apps and app updates will need to target the corresponding API level or higher.

I believe this is of great importance for React Native since the current default targetSdkVersion seems to be 22. And thus I can only deduce that React Native is not ready for a higher Android API Level. Yes, people have been using React Native using higher API levels but it seems that it's not stable. Time to bump the API Level? Or make sure that everything will work on 26?

TL;DR: You will not be able to release a _stable_ React Native application through the Play Store if you use the default targetSdkVersion starting August 2018. Be ready.

Android Ran Commands Fixed Locked

Most helpful comment

According to the changelog for the coming RN version 0.56, compiling using Android SDK 26 will be included.

Android projects are now compiled using the Android 26 SDK. The target API level is left unchanged in this release. Starting August 2018, new apps submitted to the Play Store will need to target API 26 as a minimum. You can now opt your project in to use API 26 (or newer) as the target.

https://github.com/react-native-community/react-native-releases/blob/master/CHANGELOG.md#056

All 11 comments

really looking forward for answer/infos as I already started to shift my mobile app into react-native.

I see there is a PR https://github.com/facebook/react-native/pull/17741 to update Android targetSdk but seems no one to review it.

If anyone is upgrading to SDK 28 FYI:

you'll need to add

    <application
        ....
        android:usesCleartextTraffic="${isDebug}"


        ...>

to your AndroidManifest.xml file.

and

    buildTypes {
        debug {
            manifestPlaceholders = [isDebug:true]
        }


        release {

            manifestPlaceholders = [isDebug:false]
        }
    }

to your app/build.gradle file

Thanks @joshfriend for the tip about manifest placeholders

If you're moving past SDK 23; You will need to add permission requests ala https://facebook.github.io/react-native/docs/permissionsandroid.html since the permission architecture changed.

besides that, seems to be working

you'll need to add android:usesCleartextTraffic="true" to your AndroidManifest.xml file.

This is only necessary for debug/development builds, please don't do this for release builds. Use manifest placeholders to set this appropriately for each build type.

@joshfriend thanks for the tip about automating that with placeholders. updated my comment above to drive people in the right direction.

Does anyone know how NPM modules that have native Android code configured to build with target SDK versions lower than 26 will fare? I have several modules in my project ranging from 22 to 27. How does this affect the main project?

Expect the libraries to cause problems if they use code that is restricted in newer API levels. The target level basically says 'tested on this API level'. So if the code targets 22 don't expect it to work flawlessly on higher API levels and test before starting extensive usage.

Also, if you have a library that targets 27 then your own target SDK should ideally also be 27. If you're using version 3+ of the Gradle plugin it should warn you about that. Since a lower priority attribute value is higher than the value in your project. See manifest merging heuristics in the Android docs.

That said, I have apps (non-RN) that target API 27 and are using libraries that target API 25. So it can definitely work fine.

According to the changelog for the coming RN version 0.56, compiling using Android SDK 26 will be included.

Android projects are now compiled using the Android 26 SDK. The target API level is left unchanged in this release. Starting August 2018, new apps submitted to the Play Store will need to target API 26 as a minimum. You can now opt your project in to use API 26 (or newer) as the target.

https://github.com/react-native-community/react-native-releases/blob/master/CHANGELOG.md#056

Marking as fixed, but please let us know if there's anything else needed in 0.56 that we might be missing.

That worked perfectly to me:

android/app/build.gradle:

android {
compileSdkVersion 27
buildToolsVersion "27.0.3"

defaultConfig {
    applicationId "com.rmcinspecoes"
    minSdkVersion 16
    targetSdkVersion 27
    versionCode 1
    versionName "1.0"
    ndk {
        abiFilters "armeabi-v7a", "x86"
    }        
}

android/build.gradle:

buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}

}

allprojects {
repositories {
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
maven {
url 'https://maven.google.com/'
name 'Google'
}
jcenter()
}
}

Was this page helpful?
0 / 5 - 0 ratings