Android Question [SOLVED] Desugaring error with lambdas.

JordiCP

Well-Known Member
Licensed User
Longtime User
I'm having exactly the same error as the user reported HERE when trying to desugar an AAR

B4X:
extract
merge
desugar
Exception in thread "main" java.lang.IllegalStateException: Expected a load for Lxxxxxxxxxx; to set up parameter 2 for yyyyyyyyyy but got -1
    at com.google.common.base.Preconditions.checkState(Preconditions.java:862)
    at com.google.devtools.build.android.desugar.LambdaDesugaring$InvokedynamicRewriter.attemptAllocationBeforeArgumentLoads(LambdaDesugaring.java:543)
    at com.google.devtools.build.android.desugar.LambdaDesugaring$InvokedynamicRewriter.visitInvokeDynamicInsn(LambdaDesugaring.java:427)
    ....

In the last post of that thread @Erel mentioned
It means that the library is not compatible with the desugar tool. Might require a new version of the tool. You can try to do it with Android Studio and get the desugarred jar.
Where should I find a new version of the tool, or any hint regarding how to do it with Android Studio?

Thanks in advance :)
 

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

JordiCP

Well-Known Member
Licensed User
Longtime User
Thanks Don.

The link certainly talks about desugaring, but it's talking about Android Studio projects. I can't figure out how to do the simple process to desugar an existing jar so that it can be referenced in a B4A project (probably my fault, I'm not expert in Android Studio)
 
Upvote 0

moster67

Expert
Licensed User
Longtime User
Do you have the source of the library module that generates the AAR package?
If yes, I could try and see if I can recompile the library with the "coreLibraryDesugaringEnabled" set to true.
Oops: just saw that was the link Don already posted.
See here:
B4X:
https://developer.android.google.cn/studio/releases?hl=en#4-0-0-desugar
The docs talk about the app's build gradle file. I am not sure if it can be applied to the library's build grade file.

Otherwise,
Don't know if this can be of any help. It talks about a standalone tool.
B4X:
https://www.reddit.com/r/androiddev/comments/m4cryu/generate_a_desugared_jar_using_a_standalone/
I wished I could be of further help.
Perhaps Erel has some more information and if it can be resolved.
 
Last edited:
Upvote 0

JordiCP

Well-Known Member
Licensed User
Longtime User
Hi Mike,

Do you have the source of the library module that generates the AAR package?
No, unfortunately I don't have access to the sources, just the lib.

Thanks for the bazel link, also found it and gave me some hope that this can solve the issue. Downloaded the 4.0 (I think, not in front of my other PC now) release and the sources, and tried to build a new 'desugarer' following the instructions. However, the process crashed after 5 minutes due to some jni.h header not found. It was in my Windows PC, will try later in my Mac just in case something is different.

Interesting, now I see that at the end of the same link that a user suggests to use directly D8 since it has support for standard jars


It's incredible the amount of hours that one can spend when such problems appear... :(


Thanks for your time :)
 
Upvote 0

moster67

Expert
Licensed User
Longtime User
Interesting, now I see that at the end of the same link that a user suggests to use directly D8 since it has support for standard jars
Good catch. I did not see that.
Hope you can execute that and resolve your problem.
 
Upvote 0
Top