我想编译一个开源的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。我不知道我是否应该提到其他东西,所以如果你需要任何信息,请评论。


当前回答

注意:这个答案似乎是特定的:在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或更新版本。

其他回答

简单的解决方案是下载并解压以下文件,其中包含mips64el-linux-android-4.9和mipsel-linux-android-4.9文件夹,到sdk "android-sdk\ndk-bundle\toolchains"中的toolchains文件夹中。

下载此文件和附加到工具链文件夹

如果你想在你的项目中添加NDK,那么按照以下步骤进行:

如果您使用SDK管理器安装NDK,请先卸载。(取消SDK工具并应用) 从官方网站手动下载NDK。(任何版本)如果项目旧,那么更喜欢版本17。 提取该文件。 到你的项目结构> NDK路径>添加提取文件路径这里。 构建项目。

我所遵循的解决问题的步骤如下:

Analyze ->代码清理 从列表中选择项目,并将gradle版本更新到最新。 Build ->清洁项目 Build ->制作项目

现在,与构建相关的问题可能会被报告,比如使用编译而不是实现等。

Android studio 3.2.1+

升级你的Gradle插件

classpath 'com.android.tools.build:gradle:3.2.1'

如果你现在得到这个错误:

Could not find com.android.tools.build:gradle:3.2.1.

只需将谷歌()添加到您的存储库,如下所示:

repositories {
    google()
    jcenter()
}

从IntellJ IDEA卸载旧版本SDK ->外观->系统设置-> Android SDK -> SDK平台。

安装新的Android SDK版本,无论你想要什么版本。

在安装新的SDK时,取消选中SDK工具下的NDK复选框。