打包某些输入文件使用或覆盖了已过时的 API 已解决

Error:注: 某些输入文件使用或覆盖了已过时的 API。
注: 有关详细信息, 请使用 -Xlint:deprecation 重新编译。
注: 某些输入文件使用了未经检查或不安全的操作。
注: 有关详细信息, 请使用 -Xlint:unchecked 重新编译。
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformDexWithDexForRelease'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexIndexOverflowException: Cannot merge new index 66353 into a non-jumbo instruction!

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 20s


解决办法:
app/build.gradle
android {
   ...
    lintOptions {
        abortOnError false
    }

    dexOptions {
        jumboMode true
    }
}
root/build.gradle
buildscript {
...
}
allprojects {
...
}
task clean(type: Delete) {
   ...
}
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/build.gradle添加:
android {
    ...
    defaultConfig {
        ...
        multiDexEnabled true
    }
}

在root/build.gradle修改:
buildscript {
...
}
allprojects {
...
    gradle.projectsEvaluated {
        tasks.withType(JavaCompile) {
            options.encoding = 'UTF-8'
            options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
        }
    }
}


  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值