Repository navigation
Binding Project - Error with Desugaring #1639
Description
I am attempting to write a binding for a third-party library. That library makes use of Java 8 features. Because of this, I have to use desugaring.
I seem to be running into an issue with desugaring, and I'm not sure where I am going wrong. Without desugaring, I get 4 build errors about missing java features. When I enable desugaring, I get one build error.
Error: java.lang.TypeNotPresentException : Type io.reactivex.functions.Action not present
The third-party library does use rxjava2, and the Action type is in the .jar(used JD-GUI to look in the jar).
I've done tons of searching and having been able to figure out what is going on or how to fix it. I'm hoping somebody with Xamarin could help.
Steps to Reproduce
- Build the attached solution
- See build error
BindingTest.zip
Expected Behavior
Android project should build.
Actual Behavior
Android project does not build.
Version Information
=== Visual Studio Community 2017 for Mac ===
Version 7.4.3 (build 10)
Installation UUID: cb04a5a4-cb32-4108-987e-e5123c1b9a67
Runtime:
Mono 5.8.1.0 (2017-10/6bf3922f3fd) (64-bit)
GTK+ 2.24.23 (Raleigh theme)
Package version: 508010000
=== NuGet ===
Version: 4.3.1.4445
=== .NET Core ===
Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
2.0.5
2.0.0
1.1.1
1.0.4
SDK: /usr/local/share/dotnet/sdk/2.1.4/Sdks
SDK Versions:
2.1.4
2.0.0
1.0.3
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/5.8.1/lib/mono/msbuild/15.0/bin/Sdks
=== Xamarin.Profiler ===
Version: 1.6.1
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler
=== Apple Developer Tools ===
Xcode 9.2 (13772)
Build 9C40b
=== Xamarin.Mac ===
Version: 4.2.1.29 (Visual Studio Community)
=== Xamarin.iOS ===
Version: 11.9.1.24 (Visual Studio Community)
Hash: f62de472
Branch: xcode9.3
Build date: 2018-03-29 19:30:53-0400
=== Xamarin.Android ===
Version: 8.2.0.16 (Visual Studio Community)
Android SDK: /Users/ralford/Library/Developer/Xamarin/android-sdk-macosx
Supported Android versions:
4.2 (API level 17)
4.4 (API level 19)
5.0 (API level 21)
5.1 (API level 22)
6.0 (API level 23)
7.0 (API level 24)
7.1 (API level 25)
8.0 (API level 26)
8.1 (API level 27)
SDK Tools Version: 26.1.1
SDK Platform Tools Version: 27.0.1
SDK Build Tools Version: 27.0.3
Java SDK: /usr
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL
=== Xamarin Inspector ===
Version: 1.4.0
Hash: b3f92f9
Branch: master
Build date: Fri, 19 Jan 2018 22:00:34 GMT
Client compatibility: 1
=== Build Information ===
Release ID: 704030010
Git revision: 5af3e98549653fcc5335896ccc296343d08f31bb
Build date: 2018-04-12 12:32:07-04
Xamarin addins: fadb82fb0fe2668cb7789f8b524aec6fb8568ee7
Build lane: monodevelop-lion-d15-6
=== Operating System ===
Mac OS X 10.12.6
Darwin 16.7.0 Darwin Kernel Version 16.7.0
Mon Nov 13 21:56:25 PST 2017
root:xnu-3789.72.11~1/RELEASE_X86_64 x86_64
=== Enabled user installed addins ===
Internet of Things (IoT) development (Preview) 7.1
Activity
jonathanpeppers commentedon May 16, 2018
So I'm able to repro on 15.7 stable with the sample project, here is the log of interest:
When I decompile

obj\Debug\lp\1\jl\__reference__rxjava-2.1.2.jar, it appears to have the class it's complaining about:@atsushieno do you see anything here?
atsushieno commentedon May 17, 2018
Those Java libraries are included in the project as EmbeddedReferenceJar, which is wrong. If they have to be packaged in the apk, they have to be EmbeddedJar (for *.jar) and LibraryProjectZip (for *.aar) for each.
atsushieno commentedon May 17, 2018
I was trying to get it working, with the command like:
but even desugar_deploy.jar built from https://github.com/bazelbuild/bazel/tree/master/src/tools/android/java/com/google/devtools/build/android/desugar (build instruction can be found at https://github.com/webrtc-uwp/chromium-third_party/tree/master/bazel/desugar) results in the same.
Removing the last two options make it pass, which means desugar fails to resolve those types in rxjava2 jars.
At this state I can only think of issues in desugar itself.
eclipsed4utoo commentedon May 17, 2018
@atsushieno Does this mean I need to report an issue with bazel instead?
Thanks for looking into the issue.
erikpowa commentedon Sep 5, 2018
@atsushieno it's XA sided bug see
atsushieno commentedon Sep 5, 2018
(I believe either @jonathanpeppers or @dellis1972 works on those kind of issues nowadays after I left the team.)
gmoney494 commentedon Sep 11, 2018
@jonathanpeppers @atsushieno
I also have a similar issue but with a different class in the
io.reactivexnamespace. However, i ingest via the nuget package by Naxam. This suffices my dependency requirement for the native Aar im trying to bind.Any easy solution or workaround for the time being or do i have to wait for a new release?
Added --classpath_entry for Desugar (#2158)
sgong-pdftron commentedon May 29, 2019
Any update on this issue? Or workaround?
jonathanpeppers commentedon May 30, 2019
I retested this with VS 2019 16.1.1. I had to update
Plugin.CurrentActivityto latest, not sure why.It looks like d8/r8 can handle the desugaring just fine now:
You can add
<AndroidDexTool>d8</AndroidDexTool>to your.csprojfile.@eclipsed4utoo closing this for now. Let us know if d8 solves the problem for you!