Skip to content

Multi-version jar file problem with Android SDK #510

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
svenjacobs opened this issue Aug 24, 2018 · 18 comments
Closed

Multi-version jar file problem with Android SDK #510

svenjacobs opened this issue Aug 24, 2018 · 18 comments
Assignees
Labels

Comments

@svenjacobs
Copy link

svenjacobs commented Aug 24, 2018

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, etc
  • class name (kotlinx/coroutines/experimental/scheduling/LimitingDispatcher) does not match path (META-INF/versions/9/kotlinx/coroutines/experimental/scheduling/LimitingDispatcher.class), etc

ORIGINAL 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

@elizarov
Copy link
Contributor

elizarov commented Aug 24, 2018

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

@elizarov elizarov changed the title 0.25.0 requires Android O (API 26) Multi-version jar file problem with Android SDK (MethodHandle.invoke and MethodHandle.invokeExact) Aug 24, 2018
@svenjacobs
Copy link
Author

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/**/*'
    }
}

@elizarov elizarov changed the title Multi-version jar file problem with Android SDK (MethodHandle.invoke and MethodHandle.invokeExact) Multi-version jar file problem with Android SDK Aug 25, 2018
@elizarov
Copy link
Contributor

elizarov commented Aug 25, 2018

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:

  • Gradle version 4.9
  • Android Gradle Tools version to 3.3.0-alpha04

Please, confirm that it helps with other applications, too.

@elizarov elizarov self-assigned this Aug 25, 2018
@elizarov elizarov added the bug label Aug 25, 2018
@matejdro
Copy link

matejdro commented Aug 26, 2018

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.

@SUPERCILEX
Copy link
Contributor

@elizarov I got that error using AGP 3.3.0-alpha07 and Gradle 4.10.

@elizarov
Copy link
Contributor

@SUPERCILEX It seems that you need R8 to be enabled un your gradle.properties (only latest R8 supports mutli-version jars properly).

@SUPERCILEX
Copy link
Contributor

SUPERCILEX commented Aug 26, 2018

@elizarov Ohhhhh, I enabled R8 a few commits later. I'll try and report back.

@elizarov
Copy link
Contributor

elizarov commented Aug 26, 2018

@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.

@SUPERCILEX
Copy link
Contributor

@elizarov Nope, it still fails with R8 enabled: Caused by: com.android.tools.r8.errors.CompilationError: Program type already present: kotlinx.coroutines.experimental.AbstractContinuation.

@svenjacobs
Copy link
Author

@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.

@tepex
Copy link

tepex commented Aug 28, 2018

In my case it was 0.25.0 coroutines. 0.24.0 -- is OK.

@igorvilela28
Copy link

I'm with this problem too.

Using coroutines 0.25.0, AGP 3.3.0-alpha05 and gradle 4.9

@cbruegg
Copy link

cbruegg commented Aug 30, 2018

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.

@qwwdfsad
Copy link
Member

We're going to revert multirelease JAR

@Mracobes9
Copy link

So someone know how to fix it ?

@ezamelczyk
Copy link

@Mracobes9 revert to 0.24.0

@Mracobes9
Copy link

@ezamelczyk . revert what ? Coroutines ?

elizarov added a commit that referenced this issue Aug 31, 2018
* Distribution no longer uses multi-version jar (unsuppored on Android)
* JS version of the library does not deneds on AtomicFu:
  All the atomic boxes in JS are fully erased.

Fixes #510
@elizarov elizarov mentioned this issue Sep 4, 2018
@elizarov
Copy link
Contributor

elizarov commented Sep 4, 2018

Use kotlinx.coroutines version 0.25.3.

qwwdfsad pushed a commit that referenced this issue Sep 6, 2018
* Distribution no longer uses multi-version jar (unsuppored on Android)
* JS version of the library does not deneds on AtomicFu:
  All the atomic boxes in JS are fully erased.

Fixes #510
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

10 participants