https://kotlinlang.org logo
#build-tools
Title
# build-tools
l

Lucy

01/16/2023, 7:05 PM
Hello, 🙂 has anyone noticed differences with minification and Kotlin 1.8.0 (kotlin-gradle-plugin)? I'm building an Android library with minified enabled and the resulting class files are completely different from Kotlin 1.7.2. Example using 1.7.2 and minify
Copy code
public final class Test public constructor() {
    public final fun addOne(num: <http://kotlin.Int|kotlin.Int>): <http://kotlin.Int|kotlin.Int> { /* compiled code */ }

    public final suspend fun suspendAddOne(num: <http://kotlin.Int|kotlin.Int>): <http://kotlin.Int|kotlin.Int> { /* compiled code */ }
}
Same code after using 1.8.0 and minify
Copy code
public final class Test {
    public static final int $stable;

    public Test() {
    }

    public final Object suspendAddOne(int var1, Continuation<? super Integer> var2) {
        return Boxing.boxInt(var1 + 1);
    }

    public final int addOne(int var1) {
        return var1 + 2;
    }
}
In 1.8.0, I am also getting an extra parameter variable with suspend functions. I can't find any documentation or logs about this change (looked at kotlin, gradle, and minify/R8 release pages). If anyone could point me in the right direction it would be greatly appreciated!
e

ephemient

01/17/2023, 12:52 AM
the
Continuation
parameter has always been there in all versions, that's how `suspend fun`s are implemented. how are you inspecting the class files?
l

Lucy

01/17/2023, 7:48 AM
I'm using the android studio APK analyzer to inspect the aar files. In the above examples, I was using Android Gradle Plugin version 7.4.0, but after upgrading that to 7.2.0, I was actually able to get the same result with Kotlin 1.8.0 and 1.7.20, with no
continuation
parameter seen in the APK analyzer.
Thanks for taking a look! 🙏
e

ephemient

01/17/2023, 8:07 AM
it's possible that the version of kotlinx.metadata pulled in by the plugin affects whether it understands how recover the signature of the
suspend fun
or not. but that's purely for display, it's always there in the bytecode. you can use low-level tools like
javap
or
baksmali
to see
🤔 1
👀 1
l

Lucy

01/17/2023, 8:44 AM
Ah I see. I'll try those tools out next time! Thanks!
23 Views