【问题标题】:NDK build for Android 11(R) not supported不支持 Android 11(R) 的 NDK 构建
【发布时间】:2020-09-11 22:42:23
【问题描述】:

有没有为 android R image 构建 C/C++ 项目?

我得到:“C/C++ release|x86_64: API codeName 'R' is not supported by NDK 'D:\Android_sdk\ndk\21.1.6352462” 错误。

这是项目结构:

我使用 Android Studio 4 RC1Android R PreviewNDK 21.1 版 进行此构建。

这是 gradle 配置:

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'

}

【问题讨论】:

    标签: android android-studio android-ndk


    【解决方案1】:

    根据this comment,您需要从金丝雀频道安装更新的NDK:

    Android Studio 菜单,“设置 > 外观和行为 > 系统设置 > 更新”
    选择“金丝雀频道”
    Canary NDK 将启用下载:
    “工具 > SDK 管理器 > SDK 工具”
    (假设“显示包详细信息”已启用)“NDK 并排”

    或者你可以从命令行安装它

    sdkmanager --channel=3 --install 'ndk;21.1.6363665'
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-02-17
      • 2013-10-19
      • 1970-01-01
      • 2019-02-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-26
      相关资源
      最近更新 更多