Gradle Build Error java.lang.IllegalArgumentException

时间:2017-11-23 22:19:12

标签: java android gradle

当我想启动项目时,我收到了成绩构建错误。就是这样:

Error:Execution failed for task ':app:processDebugResources'.
> java.lang.IllegalArgumentException (no error message)

我将一些东西粘贴到这个项目中,之前导致了一些错误,因此复制/粘贴可能会出错...

这是我的build.grade文件:

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

allprojects {
    repositories {
        jcenter()
    }
}

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

和另一个build.gradle文件:

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.2"
    defaultConfig {
        applicationId "com.example.leodr.upgradeadmin"
        minSdkVersion 15
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile files('libs/gson-1.4.jar')
    compile 'com.android.support:appcompat-v7:26.+'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'
}

我希望你能帮助我,TY的帮助!

1 个答案:

答案 0 :(得分:0)

更新您的项目级build.grade

// 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:3.0.1'

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

allprojects {
    repositories {
        jcenter()
        google()
    }
}

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

和您的模块级别build.gradle

更改这些行:

compileSdkVersion 26
buildToolsVersion "26.0.2"

为:

compileSdkVersion 27 //buildToolsVersion is not needed

targetSdkVersion 26

为:

targetSdkVersion 27

和依赖行:

compile 'com.android.support:appcompat-v7:26.+'

为:

compile 'com.android.support:appcompat-v7:27.0.1'

现在同步您的项目,如果它提示您下载,只需点击错误中的链接即可下载。