Repository navigation
Description
Steps to Reproduce
- I have a .jar file which builds okay with Xamarin.Android 10.0.x version
- The same .jar file fails to build on latest Xamarin.Android 10.2.0.100 version.
Expected Behavior
The same .jar file builds okay regardless of the Xamarin.Android version.
Actual Behavior
On Xamarin.Android 10.2 some classes from .jar file does not show up in api.xml file during 'exporting JAR to XML' build step and thus missing classes cause compilation errors. The same .jar file works fine with Xamarin.Android 10.0 version. There are no logs related to that missing classes, they just don't show up in api.xml file.
Version Information
Microsoft Visual Studio Community 2019
Version 16.5.4
VisualStudio.16.Release/16.5.4+30011.22
Microsoft .NET Framework
Version 4.8.03752
Installed Version: Community
Details
Visual C++ 2019 00435-60000-00000-AA532 Microsoft Visual C++ 2019ASP.NET and Web Tools 2019 16.5.236.49856
ASP.NET and Web Tools 2019
Azure App Service Tools v3.0.0 16.5.236.49856
Azure App Service Tools v3.0.0
C# Tools 3.5.0-beta4-20153-05+20b9af913f1b8ce0a62f72bea9e75e4aa3cf6b0e
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.
Common Azure Tools 1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.
Extensibility Message Bus 1.2.0 (d16-2@8b56e20)
Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration.
IntelliCode Extension 1.0
IntelliCode Visual Studio Extension Detailed Info
Microsoft JVM Debugger 1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines
Microsoft MI-Based Debugger 1.0
Provides support for connecting Visual Studio to MI compatible debuggers
Microsoft Visual C++ Wizards 1.0
Microsoft Visual C++ Wizards
Microsoft Visual Studio VC Package 1.0
Microsoft Visual Studio VC Package
Mono Debugging for Visual Studio 16.5.514 (c4f36a9)
Support for debugging Mono processes with Visual Studio.
NuGet Package Manager 5.5.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/
ProjectServicesPackage Extension 1.0
ProjectServicesPackage Visual Studio Extension Detailed Info
Sandcastle Help File Builder SHFB
Visual Studio integration for the Sandcastle Help File Builder.
https://github.com/EWSoftware/SHFB
Test Adapter for Boost.Test 1.0
Enables Visual Studio's testing tools with unit tests written for Boost.Test. The use terms and Third Party Notices are available in the extension installation directory.
Test Adapter for Google Test 1.0
Enables Visual Studio's testing tools with unit tests written for Google Test. The use terms and Third Party Notices are available in the extension installation directory.
Visual Basic Tools 3.5.0-beta4-20153-05+20b9af913f1b8ce0a62f72bea9e75e4aa3cf6b0e
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.
Visual F# Tools 10.8.0.0 for F# 4.7 16.5.0-beta.20181.6+85af456066acd4e76d2bc7821b44a325e46f2fca
Microsoft Visual F# Tools 10.8.0.0 for F# 4.7
Visual Studio Code Debug Adapter Host Package 1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio
Visual Studio Tools for CMake 1.0
Visual Studio Tools for CMake
VisualStudio.DeviceLog 1.0
Information about my package
VisualStudio.Foo 1.0
Information about my package
VisualStudio.Mac 1.0
Mac Extension for Visual Studio
Xamarin 16.5.000.533 (d16-5@9152e1b)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.
Xamarin Designer 16.5.0.470 (remotes/origin/d16-5@681de3fd6)
Visual Studio extension to enable Xamarin Designer tools in Visual Studio.
Xamarin Templates 16.5.49 (0904f41)
Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms.
Xamarin.Android SDK 10.2.0.100 (d16-5/988c811)
Xamarin.Android Reference Assemblies and MSBuild support.
Mono: c0c5c78
Java.Interop: xamarin/java.interop/d16-5@fc18c54
ProGuard: xamarin/proguard@905836d
SQLite: xamarin/sqlite@46204c4
Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-5@9f4ed4b
Xamarin.iOS and Xamarin.Mac SDK 13.16.0.13 (b75deaf)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.
Activity
jpobst commentedon May 7, 2020
Are you using
jar2xmlorclass-parse? (Look in your project properties.)If you're using
jar2xmlI can't imagine anything should have changed. It's been deprecated for several years and the code hasn't been modified since 2016.If you're using
class-parsethe only thing I can think of that might have changed was if the Java types/methods wereprivateand we stopped emitting them, or if this is a Kotlin library and we stopped emitting private Kotlin types/methods.If you can post the snippet of XML from your 10.0 version that is missing in the 10.2 version maybe we can see if anything looks weird about it.
adydecki commentedon May 11, 2020
We're using
class-parse. Attached are two snippets of api.xml that are completely missing in latest 10.2.0.100. There are more missing types, I'm pasting missing snippets related toCameraclass that is causing compilation issues.Missing in 10.2.0.100 version:
1)
jpobst commentedon May 12, 2020
Hmm, those look like very normal public types. I don't see any reason that they wouldn't be included in the
api.xml. The only thing I can think would be if they depend on types in other.jarfiles that aren't getting referenced, but that should result in some warnings.You could try looking in the
api.xml.class-parsefile and see if they exist there. That would tell us at which step they are going missing.If they aren't there, then I would double check that the types really do exist in the
.jarfile using a jar decompiler likejd-gui.If you can attach the
.jarfile here I can also take a look at it.adydecki commentedon May 13, 2020
I can confirm missing types do exist in the
api.xml.class-parsefile. Attached snipped code of theCameratype from that file.<class abstract="false" deprecated="not deprecated" jni-extends="Ljava/lang/Object;" extends="java.lang.Object" extends-generic-aware="java.lang.Object" final="true" name="Camera" jni-signature="Lcom/scandit/datacapture/core/source/Camera;" source-file-name="SourceFile" static="false" visibility="public"> <implements name="com.scandit.datacapture.core.source.AndroidCameraProxy" name-generic-aware="com.scandit.datacapture.core.source.AndroidCameraProxy" jni-type="Lcom/scandit/datacapture/core/source/AndroidCameraProxy;" />I'm also attaching our
.jarfile that we binds.ScanditCaptureCore.zip
jpobst commentedon May 13, 2020
It looks like this is because this is a Kotlin library and we started honoring Kotlin visibility. If you run with
Diagnosticlogging, you will see that it cannot findAndroidCameraProxy:This is because the type is marked as
internalin Kotlin, so it gets hidden:C# does not allow you to publicly expose an internal type (in this case it would be inheriting from an internal type). You can try changing the type to
publicin Kotlin and see if that fixes it.kimhongka commentedon May 14, 2020
Hi ipobst,
I am also getting this issue. My binding projects generated methods that I need on Xamarin.Android 10.1.X, but from 10.2.X it doesn't generated a few methods.
For instance, I was able get (10.1.X)
[Register("setJourneyId", "(Ljava/lang/String;)Lcom/gbgroup/idscan/bento/enterprice/RequestDocumentSend;", "")]
public unsafe RequestDocumentSend SetJourneyId(string journeyId)
From
Java
@NotNull
public final RequestDocumentSend setJourneyId(@NotNull String journeyId) {
Intrinsics.checkParameterIsNotNull(journeyId, "journeyId"); this.mJourneyId = journeyId;
return this;
}
Kotlin
@Suppress("unused")
fun setJourneyId(journeyId: String): RequestDocumentSend {
this.mJourneyId = journeyId
return this
}
But the method is NOT generated on the Xamarin.Android 10.2.X. I think it is related to the Kotlin binding part updated. That method above is not Internal. I made other binding project for other SDK. I have faced the same issue on latest Xamarin.Android.
adydecki commentedon May 14, 2020
@jpobst thank you for your investigation and providing the root cause for our issue. However we have more such scenarios where public class type inherits from internal interface type in Kotlin. Please also note that C# allows inheriting from internal interface types in public class types and in our case AndroidCameraProxy is an interface type and not a class as stated below:
Kotlin: Hiding internal class com/scandit/datacapture/core/source/AndroidCameraProxyMy question is, are you going to handle such scenarios in later releases? We could skip 10.2.0.100 if you're going to support it later.
jpobst commentedon May 14, 2020
@adydecki Good point about interfaces, they need to be resolvable. I've submitted a change that will fix this issue: dotnet/java-interop#645. Unfortunately 10.3 is already locked, but it should be in 10.4.
jpobst commentedon May 14, 2020
@kimhongka You will likely need to do the same digging in the log to determine why it is not being bound. If you Rebuild your project with at least
detailedverbosity you'll see a log of every Kotlin fixup done, for example:You'll also see the standard warnings about members being dropped and why. My guess would be that the method isn't being bound because the type
RequestDocumentSendisn't being resolved, and you'll need to follow the log to figure out what the root issue is.jpobst commentedon May 18, 2020
@kimhongka Another issue I was working on reminded me that there was an issue with hiding too many Kotlin getter/setters in 10.2: dotnet/java-interop#571.
This is fixed in 10.3, so you might want to try a 10.3 preview and see if it fixes your issue.
[XAT.Bytecode] Bind Kotlin internal interfaces as package-private (#645)
[XAT.Bytecode] Bind Kotlin internal interfaces as package-private (#645)
jpobst commentedon May 19, 2020
This has been fixed for 10.4 (16.7/8.7) via dotnet/java-interop#645.
I think Preview 3 is the first preview that will contain this fix.