2

WHEN I INSTALL MY APPLICATION AT API23, IT WORKS FINE. BUT WHEN I INSTALL MY APPLICATION AT API 16-17, IT DOESN'T EVEN COMPILES & THROWS BELOW WARNING.

How do i get rid of this warning, or atleast how should i correct my mistake.

Error at the time of running my application:

Error:Note: Some input files use unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':app:transformClassesWithDexForDebug'. com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536

  • Try: Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output.

My app level 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
}

References : Uses unchecked or unsafe operations

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

Community
  • 1
  • 1
Pawan
  • 502
  • 6
  • 27
  • Check the solution of @Aspicas in http://stackoverflow.com/questions/36643102/android-studio-2-1-instant-run-java-lang-outofmemoryerror-gc-overhead-limit-exc – Raghavendra Oct 20 '16 at 09:08
  • 2
    http://stackoverflow.com/questions/33313101/dexindexoverflowexception-only-when-running-tests – IntelliJ Amiya Oct 20 '16 at 09:16
  • @Raghavendra : It gives new error : Warning:The `android.dexOptions.incremental` property is deprecated and it has no effect on the build process. Error:The number of method references in a .dex file cannot exceed 64K. Learn how to resolve this issue at https://developer.android.com/tools/building/multidex.html – Pawan Oct 20 '16 at 09:19
  • 2
    @IntelliJAmiya : It worked, Thanks. Please post as an answer i will accept it. – Pawan Oct 20 '16 at 09:31
  • 2
    @Pawan Honestly speaking, I am not here for more reputations . Here for Friendship and knowledge transfer . I can't violet `Stackoverflow's `duplicate answer rule . Move ahead . – IntelliJ Amiya Oct 20 '16 at 09:54
  • 1
    @IntelliJAmiya : Still Thanks Bro :-) – Pawan Oct 20 '16 at 10:10

0 Answers0