首页 文章

Gradle构建错误配置项目 - Android Studio 2.3

提问于
浏览
-1

更新SDK构建工具后,错误:

Error:(1, 1) A problem occurred evaluating project ':app'.
> java.lang.UnsupportedClassVersionError: com/android/build/gradle/AppPlugin : Unsupported major.minor version 52.0

当我尝试在Android Studio 2.3中运行我的代码时收到以下错误消息

错误:配置项目':app'时出现问题 . 无法下载junit.jar(junit:junit:4.12)无法获取资源'https://jcenter.bintray.com/junit/junit/4.12/junit-4.12.jar' . 无法获取'https://jcenter.bintray.com/junit/junit/4.12/junit-4.12.jar' . akamai.bintray.com **

build.gradle文件:

buildscript {
    repositories {
        maven { url 'http://repo1.maven.org/maven2' }
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.1'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

的build.gradle(模块:APP)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion '25.0.0'

    defaultConfig {
        applicationId "palstech.com.fitnessdroid2"
        minSdkVersion 22
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.3.0'
    compile 'com.android.support:design:23.3.0'
    compile 'de.hdodenhof:circleimageview:2.1.0'
}

2 回答

  • 0

    在存储库中添加此行 .

    maven { url 'http://repo1.maven.org/maven2' }

  • 0

    在根 build.gradle 文件中指定存储库的URL,

    allprojects {
        repositories {
            maven { url 'http://repo1.maven.org/maven2' }
            jcenter { url "http://jcenter.bintray.com/" }
        }
    }
    

    刷新依赖,如果仍然无法构建尝试这个:

    application/project - > module settings - > Dependencies tab - >找 junit:junit:4.12 - >选择它并右键单击并选择 remove 选项 - >确定

    EDIT

    确保gradle插件是最新的错误:

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

相关问题