alibaba / freeline

A super fast build tool for Android, an alternative to Instant Run
https://www.freelinebuild.com/
BSD 3-Clause "New" or "Revised" License
5.48k stars 623 forks source link

对Gradle 3.0之后的desugar的支持 #942

Closed a3349384 closed 6 years ago

a3349384 commented 6 years ago

在使用android gradle 3.0之后,即使不使用retrolambda插件,也可以使用大部分Java8特性。 官方文档说明如下:

Android Studio provides built-in support for using certain Java 8 language features and third-party libraries that use them. As shown in figure 1, the default toolchain implements the new language features by performing bytecode transformations, called desugar, on the output of the javac compiler. Jack is no longer supported, and you should first disable Jack to use the Java 8 support built into the default toolchain.

我太懂python,但我还是看了一下。目前freeline是通过检测使用启用了retrolambda来确定javac的编译参数(默认是1.7,使用了retrolambda的话就是1.8)

我尝试过把这个判断去掉,并且修改代码:

javacargs = [self._javac, '-target', '1.8', '-source', '1.8', '-encoding', 'UTF-8', '-g', '-cp',
                     os.pathsep.join(self._classpaths)]

全量编译ok,增量编译出错。错误如下:

Uncaught translation error: com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)
1 error; aborting

不知,freeline能否支持Gradle 3.0中的desugar编译?

VankaIn commented 6 years ago

+1 up