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


当前回答

只需将您的Android Studio升级为最新版本>>,即可根据您的项目连接互联网下载内容。

其他回答

要解决这个问题,请转到:

工具->Sdk管理器-> Android Sdk ->Sdk工具在Android Studio和 取消选中NDK版本,只选择20.1.5948944版本并安装它。

我在linux(Ubuntu)机器上使用这种技术解决了同样的问题。

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

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)

错误信息:

在前缀为:llvm的ABI的NDK toolchains文件夹中没有找到工具链。

在使用NDK重新安装Android Studio后,我从GitHub导入了一个使用NDK的Android代码示例,并尝试编译它。

结果有一个错误:

在前缀为:llvm的ABI的NDK toolchains文件夹中没有找到工具链

解决方案: 由于某些原因,macOS上的标准安装过程未能安装完整的一套:

~/Library/Android/sdk/ndk-bundle丢失了所有工具的文件夹工具链,

(它应该是这样的:~/Library/Android/sdk/ndk-bundle/toolchains)

解决方案是单独下载NDK,打开它,复制文件夹工具链并粘贴到文件夹:

~/Library/Android/sdk/ndk-bundle

这个问题的最佳解决方案是:

进入SDK管理器。 接下来选择SDK工具。 取消选择NDK(并排)。 Apply和OK。

这个问题主要出现在你克隆以前的项目特别是从github。你能做的就是

将类路径更改为

classpath’com。android工具。构建:gradle: 1 3。2。

在你的项目级别gradle。

然后用实现改变所有的compile实例,除了compileSdkVersion,保持它在你的应用级gradle中。 现在点击创建项目(Ctrl+F9) 如果需要,添加谷歌maven存储库。 如果需要,升级gradle包装器。

(Android Studio IDE会在第4步和第5步中要求/指导你)