首页 > 解决方案 > 未找到兼容的并排 NDK 版本。默认为 20.0.5594570

问题描述

我收到上述错误

我的 gradle 看起来像这样

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

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.3"

    defaultConfig {
        applicationId "com.example.hypersignwalletcorekotlin"
        minSdkVersion 23
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

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

无法理解为什么会这样。

谢谢

标签: androidandroid-ndk

解决方案


修复:ndkVersion添加到模块的 build.gradle

    android.ndkVersion  "your-installed-ndk-version"

就像在一些例子中一样。您可以从文件 $NDK/source.properties 中找到您的 NDK 版本。

背景信息: 您可能使用 AGP/Android Studio 3.6+ 版:“从 Android Gradle Plugin (AGP) 3.6+,known good NDK添加了一个概念,即known good/tested NDK version该 AGP 版本发布的时间”。如果出现以下情况,AGP 将使用该内部 NDK 版本:

内部 NDK 预计将作为并行 NDK 位置安装: $SDK\ndk
如果未安装:

  • AGP 3.6、AGP 4.0 会报错
  • AGP 4.1 会自动安装它。

随着更新的 NDK 不断发布,内部嵌入的 NDK 版本很可能很快就会过时:如果您想使用更新的 NDK 版本,您确实需要使用 ndkVersion 配置gradle

附加文档: 详见官方文档


推荐阅读