我想编译一个开源的android项目(Netguard)使用gradel (gradlew清洁构建)但我遇到了这个错误:

A problem occurred configuring project ':app'.
> Exception thrown while executing model rule: NdkComponentModelPlugin.Rules#cre
ateToolchains
   > No toolchains found in the NDK toolchains folder for ABI with prefix: llvm

我搜索了一下,但没有发现任何有用的东西。这是主要的build.gradle:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle-experimental:0.6.0-alpha1'
    }
}
allprojects {
    repositories {
        jcenter()
    }
}
task clean(type: Delete) {
    delete rootProject.buildDir
}

这是构造。应用项目的Gradle:

apply plugin: 'com.android.model.application'

model {
    android {
        compileSdkVersion = 23
        buildToolsVersion = "23.0.2"

        defaultConfig.with {
            applicationId = "eu.faircode.netguard"
            minSdkVersion.apiLevel = 21
            targetSdkVersion.apiLevel = 23
            versionCode = 2016011801
            versionName = "0.76"
            archivesBaseName = "NetGuard-v$versionName-$versionCode"
        }
    }
    android.ndk {
        moduleName = "netguard"
        toolchain = "clang"
        ldLibs.add("log")
    }
    android.sources {
        main {
            jni {
                source {
                    srcDir "src/main/jni/netguard"
                }
                exportedHeaders {
                }
            }
        }
    }
    android.buildTypes {
        release {
            minifyEnabled = true
            proguardFiles.add(file('proguard-rules.pro'))
            ndk.with {
                debuggable = true
            }
        }
    }
    android.buildTypes {
        debug {
            ndk.with {
                debuggable = true
            }
        }
    }
    android.productFlavors {
        create("all") {
        }
    }
}

dependencies {


compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:23.1.+'
    compile 'com.android.support:recyclerview-v7:23.1.+'
    compile 'com.squareup.picasso:picasso:2.5.+'
}

我使用gradle-2.9-all和android-ndk-r10e。我不知道我是否应该提到其他东西,所以如果你需要任何信息,请评论。


当前回答

我尝试用以下方法来解决这个问题:

Stay Android build tools version the same with gradle version. For example:if you use the build tools version is 3.3.0,your gradle version must be 4.10.1.You can reference by the link https://developer.android.com/studio/releases/gradle-plugin and chagne your build tools & gradle version in your AS(File->Project Structure->Project) If method1 don't work,you can custom your ndk toolchains version to solve the problem :like download ndk18 or ndk16 , setting the ndk path is your AS(File->Project Structure->SDK Location->Android NDK Location)

其他回答

找到你自己的本地android-SDK,如果你下载了ndk的相关SDK,会有一个名为“ndk-bundle”的文件夹

里面有一个名为“toolchains”的文件夹。

我们注意到里面没有mips64el相关的文件。

解决方法如下:

点击此处,可通过浏览器单独下载NDK包。解压缩后,打开“toolchains”文件夹,将其与android-sdk->ndk-bundle->toolchains文件夹进行比较,找到缺失的文件夹,复制过去三个。重新编译,问题就解决了。

如果不使用NDK,则取消设置环境变量ANDROID_NDK_HOME。

通过将谷歌()依赖项添加到构建中的两个存储库中解决了这个问题。gradle(项目:ProjectName)。然后同步你的项目

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.2'

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

allprojects {
    repositories {
        google()
        jcenter()
    }
}

注意:这个答案似乎是特定的:在NDK toolchains文件夹中找不到ABI的工具链,前缀为:mips64el-linux-android,但它被链接到这里:

* https://stackoverflow.com/questions/52193274/no-toolchains-found-in-the-ndk-toolchains-folder-for-abi-with-prefix-mips64el-l

来自NDK r19b:

more ~/Android/Sdk/ndk-bundle/CHANGELOG.md

此版本的NDK与Android Gradle插件不兼容 3.0或更老版本。如果你看到一个错误 在前缀为mips64el-linux-android的NDK toolchains文件夹中没有找到工具链, 将项目文件更新到[使用插件3.1或更新版本]。你也会 需要升级到androidstudio3.1或更新版本。

对我来说,我认为从android studio安装android NDK可能会有一些问题。我能够以以下方式解决这个问题

下载android ndk from

https://developer.android.com/ndk/downloads/index.html

并放置在ndk-bundle中(安装android SDK的地方)。欲了解更多信息,请检查此屏幕。

https://app.box.com/s/dfi4h9k7v4h0tmbu3z9qnqx3d12fdejn