-
Notifications
You must be signed in to change notification settings - Fork 538
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
Binding Project - Error with Desugaring #1639
Comments
So I'm able to repro on 15.7 stable with the sample project, here is the log of interest:
When I decompile @atsushieno do you see anything here? |
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. |
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. |
@atsushieno Does this mean I need to report an issue with bazel instead? Thanks for looking into the issue. |
@atsushieno it's XA sided bug see |
(I believe either @jonathanpeppers or @dellis1972 works on those kind of issues nowadays after I left the team.) |
@jonathanpeppers @atsushieno Any easy solution or workaround for the time being or do i have to wait for a new release? |
Fixes: #2143 Context: #1639 Xamarin.Android's current implementation of desugar runs a command such as: java -jar desugar_deploy.jar --bootclasspath_entry ~\android-toolchain\sdk\platforms\android-28\android.jar --min_sdk_version 11 --classpath_entry xamarin-android\bin\Debug\lib\xamarin.android\xbuild-frameworks\MonoAndroid\v9.0\mono.android.jar --input Lambda.jar --output obj\Debug\android\bin\desugared\14-57-25-90-94-EE-16-09-B8-68-88-BC-9D-FC-6C-89Lambda.jar However, certain jars are failing with messages such as: Exception in thread "main" java.lang.TypeNotPresentException: Type okhttp3.Interceptor not present Or another example: Error: java.lang.TypeNotPresentException : Type io.reactivex.functions.Action not present The first fix here is to add the `--classpath_entry` flag for every `--input`, for some reason `Desugar` is not treating `--input` jars as classpath entries? Next, we expanded on the `BuildTest.Desugar` test using a complicated set of Java libraries from Maven central: proj.OtherBuildItems.Add (new BuildItem ("AndroidJavaLibrary", "okio-1.13.0.jar") { WebContent = "http://central.maven.org/maven2/com/squareup/okio/okio/1.13.0/okio-1.13.0.jar" }); proj.OtherBuildItems.Add (new BuildItem ("AndroidJavaLibrary", "okhttp-3.8.0.jar") { WebContent = "http://central.maven.org/maven2/com/squareup/okhttp3/okhttp/3.8.0/okhttp-3.8.0.jar" }); proj.OtherBuildItems.Add (new BuildItem ("AndroidJavaLibrary", "retrofit-2.3.0.jar") { WebContent = "http://central.maven.org/maven2/com/squareup/retrofit2/retrofit/2.3.0/retrofit-2.3.0.jar" }); proj.OtherBuildItems.Add (new BuildItem ("AndroidJavaLibrary", "converter-gson-2.3.0.jar") { WebContent = "http://central.maven.org/maven2/com/squareup/retrofit2/converter-gson/2.3.0/converter-gson-2.3.0.jar" }); proj.OtherBuildItems.Add (new BuildItem ("AndroidJavaLibrary", "gson-2.7.jar") { WebContent = "http://central.maven.org/maven2/com/google/code/gson/gson/2.7/gson-2.7.jar" }); proj.OtherBuildItems.Add (new BuildItem ("AndroidAarLibrary", "twitter-core-3.3.0.aar") { WebContent = "http://repo.spring.io/libs-release/com/twitter/sdk/android/twitter-core/3.3.0/twitter-core-3.3.0.aar", }); This was working, as long as you had `android:minSdkVersion="24"` in your `AndroidManifest.xml`. This wasn't ideal if you wanted to run your app on older API levels... Luckily, another command line switched solved this problem: //Added to the Desugar MSBuild task if (minApiVersion < 24) { cmd.AppendSwitch("--desugar_try_with_resources_omit_runtime_classes "); } What a crazy name for a flag! Documented by `desugar` as: --[no]desugar_try_with_resources_omit_runtime_classes (a boolean; default: "false") Omits the runtime classes necessary to support try-with-resources from the output. This property has effect only if -- desugar_try_with_resources_if_needed is used. --min_sdk_version (an integer; default: "1") Minimum targeted sdk version. If >= 24, enables default methods in interfaces. This makes sense that something would happen at API level 24... Once doing this, the `Desugar` test passes without modifying `minSdkVersion`. The expanded `Desugar` test will also greatly help with our D8/R8 implementation (#2040). This complex set of Java dependencies from Maven will be useful.
Any update on this issue? Or workaround? |
I retested this with VS 2019 16.1.1. I had to update It looks like d8/r8 can handle the desugaring just fine now:
You can add @eclipsed4utoo closing this for now. Let us know if d8 solves the problem for you! |
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
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)
=== 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
Log File
The text was updated successfully, but these errors were encountered: