Skip to content
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

Error: Invoke-customs are only supported starting with Android O #6300

Closed
QiLiKing opened this issue Nov 15, 2018 · 17 comments
Closed

Error: Invoke-customs are only supported starting with Android O #6300

QiLiKing opened this issue Nov 15, 2018 · 17 comments

Comments

@QiLiKing
Copy link

Goal

Cannot build realm with 5.8.0

Actual Results

Error: Invoke-customs are only supported starting with Android O (--min-api 26)

Steps & Code to Reproduce

Version of Realm and tooling

Realm version(s): ?
5.8.0

Realm Sync feature enabled: Yes/No

Android Studio version: ?
3.2.1

Android Build Tools version: ?
28

Gradle version: ?
3.2.1

Which Android version and device(s): ?
21

@QiLiKing
Copy link
Author

QiLiKing commented Nov 15, 2018

It works when I change realm version to 5.7.0 or minSdkVersion 26.

@realm-probot
Copy link

realm-probot bot commented Nov 15, 2018

Hey - looks like you forgot to add a T:* label - could you please add one?

@QiLiKing
Copy link
Author

android{
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

Solved!

@cmelchior
Copy link
Contributor

Hmm, this shouldn't be required. So even though it is a workaround we don't want to require it.

@cmelchior cmelchior reopened this Nov 15, 2018
@cmelchior cmelchior changed the title Cannot build realm with 5.8.0 Error: Invoke-customs are only supported starting with Android O Nov 15, 2018
@cmelchior cmelchior self-assigned this Nov 15, 2018
@bagus-setyawan
Copy link

hmm i get the error too with 5.8.0, i was downgrading to 5.7.0 and worked

@jk77
Copy link

jk77 commented Dec 11, 2018

Some more error details in case it helps:
Error: Invoke-customs are only supported starting with Android O (--min-api 26)
Caused by: com.android.tools.r8.utils.AbortException: Error: Invoke-customs are only supported starting with Android O (--min-api 26)
Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete
Caused by: com.android.builder.dexing.DexArchiveBuilderException: Error while dexing.
Caused by: com.android.builder.dexing.DexArchiveBuilderException: Failed to process /Users/mgr/.gradle/caches/transforms-1/files-1.1/realm-android-library-5.8.0.aar/c7f823427f262f54101fbb84c4c4ac4a/jars/classes.jar

@jk77
Copy link

jk77 commented Dec 11, 2018

For those interested, the error is explained here: https://developer.android.com/studio/write/java8-support

Desugar currently doesn't support MethodHandle.invoke or MethodHandle.invokeExact. If your source code or one of your module dependencies use one of these methods you need to specify minSdkVersion 26 or higher. Otherwise, you get the following error:

Dex: Error converting bytecode to dex:
Cause: signature-polymorphic method called without --min-sdk-version >= 26

In some cases, your module may not be using the invoke or invokeExact methods even when they're included in a library dependency. So, to keep using that library with minSdkVersion 25 or lower, enable code shrinking to remove unused methods. If that doesn't work, consider using an alternative library that doesn't use the unsupported methods.

The workaround of enabling Java 1.8 in the project is working for us. I didn't want to enable code shrinking in a debug build, but that might be another workaround based on the description above.

@Qubitium
Copy link

Can realm fix this 1.8 dependency? We want to use D8 but not R8 yet 1.8 requires R8 set to true in a chicken and egg loop.

@jk77
Copy link

jk77 commented Dec 13, 2018

diegomontoya I think you are mistaken about 1.8 requiring R8. The Android Studio 3.2 release notes say,

You can start using the preview version of R8 by including the following in your project’s gradle.properties file:
android.enableR8 = true

I have 1.8 enabled and only get the following warning if I specifically enable R8.

The option setting 'android.enableR8=true' is experimental and unsupported.
The current default is 'false'
Consider disabling R8 by removing 'android.enableR8=true' from your gradle.properties before publishing your app.

@Qubitium
Copy link

@jk77 If you want to use R8, you need to at least use Android 3.3RC2 which has updated R8 in beta form.

Run your probject in AS 3.3 and you will get desugaring requirements requires R8 to be enabled.

We have not tested using AS 3.2 as R8 in that build is not the latest.

@Qubitium
Copy link

@jk77 Looks like the error is buildconfig dependend. I can no longer reproduce the R8 desugaring requirement error from AS 3.3rc2. Must be some thing I have chagend in build.gradle within the last 24 hours.

@cmelchior
Copy link
Contributor

The Java 8 code has been removed (lamdas) and a fix should be in the next release.

@afridi315
Copy link

Try to decrease version of Google Cloud dependency if you are using

@GuptaRaghav
Copy link

Try to decrease version of Google Cloud dependency if you are using

afridi315 have tried downgrading from 1.22.1 to 1.20.0 option but now it is giving More than one file was found with OS independent path 'META-INF/INDEX.LIST'

@victorhez
Copy link

how can i get the realm

@Zhuinden
Copy link
Contributor

@victorhez you might want to open a new issue, that obeys the issue template when you open a new issue.

@Sanaebadi97
Copy link

Sanaebadi97 commented Aug 9, 2020

  compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

in build Gradle of the app module

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests