【问题标题】:Gradle build error configuring project - Android Studio 2.3Gradle 构建错误配置项目 - Android Studio 2.3
【发布时间】:2017-10-06 11:20:36
【问题描述】:

更新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(Module: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'
}

【问题讨论】:

  • 发布您的build.gradle
  • @JaredBurrows 这是 build.gradle 文件:buildscript { repositories { maven { url 'http://repo1.maven.org/maven2' } jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.3.1' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { jcenter() } } task clean(type: Delete) { delete rootProject.buildDir }
  • 请在您的问题中发布,格式化。
  • @JaredBurrows 我已经编辑了问题,请检查。感谢您的帮助。
  • 请务必发布您的两个build.gradle 文件。在allprojects 块中有jcenter(),这很好。

标签: java android android-studio junit build.gradle


【解决方案1】:

在存储库中添加这一行。

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

【讨论】:

  • 感谢您的意见。我按照说的做了导致另一个错误:Error:Execution failed for task ':app:compileDebugRenderscript'. > com/android/jill/api/ConfigNotSupportedException
【解决方案2】:

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

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

如果仍然无法构建,请刷新依赖项:

应用程序/项目 -> 模块设置-> 依赖项标签 -> 找到 junit:junit:4.12 -> 选择它并右键单击并选择 remove 选项 -> ok

编辑

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

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

【讨论】:

  • 这没有意义,而且是多余的。
  • @JaredBurrows 我建议添加maven repo,可能无法在jcenter 中找到它,我知道在 jcenter 中可用。在其他建议中,一些时间工件与项目相关联但未选择依赖项,因此我通知进行交叉检查
  • @AbhishekAryan 删除 junit:junit:4.12 组件有所帮助。我现在可以同步和运行我的项目。非常感谢您的帮助!
猜你喜欢
  • 2017-08-13
  • 2017-07-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-07-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多