首页 > 解决方案 > 此项目的 Gradle 设置尚未配置 - android studio

问题描述

我正在尝试加载现有项目,但遇到了以下问题:

在此处输入图像描述

点击确定我会得到这个:

在此处输入图像描述

在此处输入图像描述

在这里搜索我没有找到 gangle 2.2.2。最小三角为 3.0.0

build.grandle

  // Top-level build file where you can add configuration options common to all sub-projects/modules.

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

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

allprojects {
repositories {
    jcenter()
    }
}

app.build.grande

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion '23.0.2'

defaultConfig {
    applicationId "com.prouast.heartbeat"
    minSdkVersion 15
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
}

// add a task that calls regular ndk-build(.cmd) script from app directory
task ndkBuild(type: Exec, description: 'Compile JNI source via NDK') {
    def ndkDir = android.ndkDirectory
    commandLine "$ndkDir/ndk-build",
            '-C', file('src/main/jni').absolutePath, // relative path to jni source
            'NDK_LIBS_OUT=../jniLibs',
            '-j', Runtime.runtime.availableProcessors(),
            'all',
            'NDK_DEBUG=1'
}

task ndkClean(type: Exec, description: 'Clean JNI object files') {
    def ndkDir = android.ndkDirectory
    commandLine "$ndkDir/ndk-build",
            '-C', file('src/main/jni').absolutePath, // relative path to jni source
            'NDK_LIBS_OUT=../jniLibs',
            'clean'
}

// add this task as a dependency of Java compilation
tasks.withType(JavaCompile) {
    compileTask -> compileTask.dependsOn(['ndkBuild'])
}

clean.dependsOn(['ndkClean'])

sourceSets.main {
    jni.srcDirs = []
    //jniLibs.srcDir 'src/main/libs'
}

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

dependencies {
compile 'org.apache.commons:commons-io:1.3.2'
compile 'com.android.support:appcompat-v7:23.1.1'
compile project(':libraries:opencv')
}

需要我在 app grandle 上更改某些内容或有人有什么建议吗?您能否建议我一些链接来遵循或逐步解释我该如何解决?

编辑

:将 jcenter 添加到 gradle.build 解决了这个问题:
buildscript {
    repositories {
    mavenLocal()
    mavenCentral()
    jcenter()
}

标签: androidbuild.gradle

解决方案


只需单击 OK 即可让 Studio 自动执行 Gradle 配置。


推荐阅读