Android Studio中的Gradle构建错误或错误

时间:2016-02-12 13:45:44

标签: android android-gradle build.gradle

我跟着this SO answer修复,当Android工作室给我错误 Gradle插件已经过时时,现在有一些问题,现在我收到错误 SAXParseException 这是错误的信息。

Error:org.xml.sax.SAXParseException; lineNumber: 0; columnNumber: 0; cvc-pattern-valid: Value 'build-tools;23.0.0 rc3' is not facet-valid with respect to pattern '[a-zA-Z0-9_\-;.]+' for type 'segmentListType'.

这是我的 build.gradle(模块:应用)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.jutt.fyp.isec"
        minSdkVersion 14
        targetSdkVersion 22
        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:22.2.1'
}

build.gradle(项目:测试)

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

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

        // 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
}

我尝试跟踪SO answer fix并且它没有用,我认为有问题或者再次更新?

2 个答案:

答案 0 :(得分:1)

删除此

$ANDROID_HOME/build-tools/and remove the 23.0.0-preview directory fixed the errors.

示例:在Windows中

C:\Users\Sharma\Desktop\xxx\Android\sdk\build-tools

希望这有帮助

答案 1 :(得分:0)

删除23.0.0-preview /(如gvsharma指出)和23.0.0_rc1 /解决了我的问题。

实施例

[root@cobalt Sdk]# ls
add-ons  build-tools  docs  extras  licenses  lldb  ndk-bundle  platforms  platform-tools  samples  SDK Readme.txt  sources  system-images  temp  tools
[root@cobalt Sdk]# cd build-tools/
[root@cobalt build-tools]# ls
17.0.0  18.0.1  18.1.0  18.1.1  19.0.1  19.0.2  19.0.3  19.1.0  20.0.0  21.0.0  21.0.1  21.0.2  21.1.2  22.0.1  23.0.0-preview  23.0.0_rc1  23.0.1  23.0.2  android-4.4  android-4.4W
[root@cobalt build-tools]# rm -rf 23.0.0-preview/
[root@cobalt build-tools]# rm -rf 23.0.0_rc1