从buildToolsVersion '24 .0.2'切换到更高版本时出现构建错误 [英] Build errors when switching from buildToolsVersion '24.0.2' to anything higher

查看:371
本文介绍了从buildToolsVersion '24 .0.2'切换到更高版本时出现构建错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当使用以下命令切换到buildTooolsVersion 24.0.3或更高版本时,构建失败 与默认方法和静态方法有关的错误消息"Android API级别低于24不支持"

Build fails when switching to buildTooolsVersion 24.0.3 or higher with error messages relating to Default methods and Static methods "not supported in Android API level less than 24"

在之前版本的Build Tools(最高24.0.2)中可以正常工作 我正在使用Jack和Google Play服务. 但是,抱怨与java.util和java.lang中的代码有关.例如:

Works fine in previous versions of Build Tools, up to 24.0.2 I am using Jack, and Google play-services. However, the complaints are about code in java.util and java.lang For example:

错误:SortedSet.java:36-37:Android API级别低于24.0.2时不支持默认方法java.util.Spliterator spliterator()

Error:SortedSet.java:36-37: Default method java.util.Spliterator spliterator() not supported in Android API level less than 24.0.2

错误:Stream.java:68-69:Android API级别低于24的静态方法java.util.stream.Stream $ Builder builder()

Error:Stream.java:68-69: Static method java.util.stream.Stream$Builder builder() not supported in Android API level less than 24

minSdkVersion 17 targetSdkVersion 24

minSdkVersion 17 targetSdkVersion 24

推荐答案

我切换了Android Studio以使用打包的Java 8版本.

I switched my android studio to use the packaged java 8 version.

当我切换到Java 8时,我已经将启用的jack和版本添加到8,但这破坏了发行版的所有功能.

When I switched to java 8 I had added the jack enabled and version to 8, but this broke everything for a release build.

然后我将其从true切换为false.

I then switched this from true to false.

jackOptions {
                enabled false
            }

然后将其从8设置为7.

I then set this from 8 to 7.

compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }

我猜测只要您的代码和项目中包含的库都适用于Java 7,您的代码就应该发布.

I am guessing as long as your code and the libraries you include in your project will work for java 7, your code should build for release.

如果这行不通,并且您必须使用这些Java函数,则似乎需要将最低版本提高到24.

If this doesn't work and you must use those java functions, it would seem that you will need to move you min version up to 24.

这篇关于从buildToolsVersion '24 .0.2'切换到更高版本时出现构建错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆