Gradle编译错误Android Studio -Xlint:未选中以获取详细信息

时间:2016-10-20 09:07:09

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

当我在API23上安装我的应用程序时,它的工作非常精细。 但是当我在API 16-17安装我的应用程序时,它甚至没有编译 &安培;下面的警告。

我如何摆脱这个警告,或至少我应该如何纠正我的错误。

运行我的应用程序时出错:

  

错误:注意:某些输入文件使用未经检查或不安全的操作。注意:   使用-Xlint重新编译:取消选中以获取详细信息。失败:构建失败   除了。

     
      
  • 出了什么问题:任务执行失败':app:transformClassesWithDexForDebug'。   com.android.build.api.transform.TransformException:com.android.ide.common.process.ProcessException:   java.util.concurrent.ExecutionException:   com.android.dex.DexIndexOverflowException:方法ID不在[0,   0xffff]:65536

  •   
  • 尝试:使用--stacktrace选项运行以获取堆栈跟踪。使用--debug选项运行以获得更多日志输出。

  •   

我的应用级别Build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.3"
    defaultConfig {
        applicationId "com.chsoneresidential.chsone"
        minSdkVersion 11
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    lintOptions {
        abortOnError false        // true by default
        checkAllWarnings false
        checkReleaseBuilds false
        ignoreWarnings true       // false by default
        quiet true                // false by default
    }

}

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 'com.android.support:appcompat-v7:24.2.1'
    compile 'com.android.support:design:24.2.1'
    compile 'org.androidannotations:androidannotations:4.1.0'
    compile 'com.android.support:support-v4:24.2.1'
    compile 'com.google.android.gms:play-services:9.6.1'
    testCompile 'junit:junit:4.12'
}

tasks.withType(JavaCompile) {
    // Try to turn them all off automatically
    options.compilerArgs << '-Xlint:none'
    options.compilerArgs << '-nowarn' // same as '-Xlint:none'

    // Turn them off manually
    options.compilerArgs << '-Xlint:-auxiliaryclass'
    options.compilerArgs << '-Xlint:-cast'
    options.compilerArgs << '-Xlint:-classfile'
    options.compilerArgs << '-Xlint:-deprecation'
    options.compilerArgs << '-Xlint:-dep-ann'
    options.compilerArgs << '-Xlint:-divzero'
    options.compilerArgs << '-Xlint:-empty'
    options.compilerArgs << '-Xlint:-fallthrough'
    options.compilerArgs << '-Xlint:-finally'
    options.compilerArgs << '-Xlint:-options'
    options.compilerArgs << '-Xlint:-overloads'
    options.compilerArgs << '-Xlint:-overrides'
    options.compilerArgs << '-Xlint:-path'
    options.compilerArgs << '-Xlint:-processing'
    options.compilerArgs << '-Xlint:-rawtypes'
    options.compilerArgs << '-Xlint:-serial'
    options.compilerArgs << '-Xlint:-static'
    options.compilerArgs << '-Xlint:-try'
    options.compilerArgs << '-Xlint:-unchecked'
    options.compilerArgs << '-Xlint:-varargs'
}

app.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.2.1'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
    }
}

allprojects {
    repositories {
        mavenCentral()
        mavenLocal()
    }

    tasks.withType(org.gradle.api.tasks.compile.JavaCompile){
        options.compilerArgs << "-Xlint:deprecation"
    }
}

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

参考文献:Uses unchecked or unsafe operations

How do I suppress warnings when compiling an android library with gradle?

0 个答案:

没有答案