有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

安卓 Gradle生成错误java。lang.IllegalArgumentException

当我想启动我的项目时,我得到了一个等级构建错误。事情是这样的:

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

我复制粘贴了一些东西到这个项目中,这导致了一些错误之前,所以它可能是一个错误,因为复制/粘贴

这是我的身材。成绩档案:

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

allprojects {
    repositories {
        jcenter()
    }
}

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

还有另一个版本。gradle文件:

    apply plugin: 'com.安卓.application'

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

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

我希望你能帮助我,泰谢谢你的帮助


共 (1) 个答案

  1. # 1 楼答案

    更新项目级别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'
    

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