Build errors when switching from buildToolsVersion '24.0.2' to anything higher

為{幸葍}努か 提交于 2019-12-11 03:26:27

问题


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"

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:

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

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


回答1:


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

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

I then switched this from true to false.

jackOptions {
                enabled false
            }

I then set this from 8 to 7.

compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_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.

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.



来源:https://stackoverflow.com/questions/40640783/build-errors-when-switching-from-buildtoolsversion-24-0-2-to-anything-higher

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!