NDK build for Android 11(R) not supported Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of NDK build for Android 11(R) not supported without wasting too much if your time.

The question is published on by Tutorial Guruji team.

Is there anyway to build C/C++ project for android R image ?

im getting : “C/C++ release|x86_64 : API codeName ‘R’ is not supported by NDK ‘D:Android_sdkndk21.1.6352462” error.

this is project stracture :

enter image description here

Im using Android Studio 4 RC1 , Android R Preview and NDK Version 21.1 for this build.

this is the gradle config :

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion "android-R"
    buildToolsVersion "30.0.0 rc4"

    defaultConfig {
        applicationId "com.example.myapplication"
        minSdkVersion "R"
        targetSdkVersion "R"
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        externalNativeBuild {
            cmake {
                cppFlags "-std=c++17"
            }
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    externalNativeBuild {
        cmake {
            path "src/main/cpp/CMakeLists.txt"
            version "3.10.2"
        }
    }
}

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    implementation 'androidx.core:core-ktx:1.2.0'
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

}

Answer

As per this comment, you need to install a newer NDK from the canary channel:

Android Studio menu,”settings > Appearance & Behavior > system Settings > Updates”
choose “Canary Channel”
The canary NDKs will be enabled for download:
“Tools > Sdk Manager > SDK Tools”
( assuming “Show Package Details” is enabled ) “NDK side by side”

Or you can install it from the command line with

sdkmanager --channel=3 --install 'ndk;21.1.6363665'
We are here to answer your question about NDK build for Android 11(R) not supported - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji