UPDATE (from @elizarov): JEP 238 multi-version jars seem to be causing various issue with google toolchain. Reported thus far:
MethodHandle.invoke and MethodHandle.invokeExact are only supported starting with Android O (--min-api 26)Program type already present: kotlinx.coroutines.experimental.InvokeOnCancellation, Program type already present: kotlinx.coroutines.experimental.internal.LockFreeMPMCQueueNode, etcclass name (kotlinx/coroutines/experimental/scheduling/LimitingDispatcher) does not match path (META-INF/versions/9/kotlinx/coroutines/experimental/scheduling/LimitingDispatcher.class), etcORIGINAL REPORT:
Trying to compile an Android project with min SDK 19 and the newly released 0.25.0 I suddenly receive the following build error:
MethodHandle.invoke and MethodHandle.invokeExact are only supported starting with Android O (--min-api 26)
Android Studio: 3.1.4
Android Gradle Plugin: 3.1.4
You need to exclude classes that are inside of META-INF directory of the jar file. That will be fixed in the upcoming update of the Android toolchain, see https://issuetracker.google.com/issues/77587908
Can you please tell me how to exclude these classes? I've tried different solutions but nothing seems to work:
android {
sourceSets.main.java.filter.exclude 'META-INF/**/*'
packagingOptions {
exclude 'META-INF/**/*'
}
}
Example applications for Android that are included in kotlinx.coroutines (example-app and animation-app were failing for the same reason (see #512). The following toolchain versions seem to fix the problem for those applications:
4.93.3.0-alpha04Please, confirm that it helps with other applications, too.
Is there a workaround for this issue without using alpha-stability components?
Not even Grade plugin 3.2 is out, so I imagine that stable version for 3.3 will take a long time.
@elizarov I got that error using AGP 3.3.0-alpha07 and Gradle 4.10.
@SUPERCILEX It seems that you need R8 to be enabled un your gradle.properties (only latest R8 supports mutli-version jars properly).
@elizarov Ohhhhh, I enabled R8 a few commits later. I'll try and report back.
@matejdro We don't have another workaround at the moment, but to update to the latest alpha version of toolchain. You should be able just to filter all the classes from META-INF/versions, but I'm not ad Android expert and I don't know where can you configure this kind of filter and wether it is possible at all.
@elizarov Nope, it still fails with R8 enabled: Caused by: com.android.tools.r8.errors.CompilationError: Program type already present: kotlinx.coroutines.experimental.AbstractContinuation.
@elizarov Would it be possible to release an artifact of the coroutines library for android without multi-version jar? Like @matejdro said I, too, hesitate to use an alpha version of the build toolchain for my production application.
In my case it was 0.25.0 coroutines. 0.24.0 -- is OK.
I'm with this problem too.
Using coroutines 0.25.0, AGP 3.3.0-alpha05 and gradle 4.9
Indeed the complete switch to multi-version JARs seems a bit premature. Especially when multiple developers are working on a project, it's not easy to switch to alpha-level build components.
We're going to revert multirelease JAR
So someone know how to fix it ?
@Mracobes9 revert to 0.24.0
@ezamelczyk . revert what ? Coroutines ?
Use kotlinx.coroutines version 0.25.3.
Most helpful comment
We're going to revert multirelease JAR