Java Binding api.xml.class-parse : warning BG8605: The Java type '$' could not be found

Issue

I’m trying to create C# bindings over ‘mcumgr-ble.aar’

https://mvnrepository.com/artifact/io.runtime.mcumgr/mcumgr-ble/0.12.0-beta4

I have downloaded all the dependencies of the .aar file:

    kotlinx-coroutines-android.jar
    kotlinx-coroutines-core-jvm.jar
    kotlinx-coroutines-core.jar
    kotlinx-coroutines-debug.jar
    kotlinx-coroutines-guava.jar
    kotlinx-coroutines-javafx.jar
    kotlinx-coroutines-jdk8.jar
    kotlinx-coroutines-jdk9.jar
    kotlinx-coroutines-play-services.jar
    kotlinx-coroutines-reactive.jar
    kotlinx-coroutines-reactor.jar
    kotlinx-coroutines-rx2.jar
    kotlinx-coroutines-rx3.jar
    kotlinx-coroutines-slf4j.jar
    kotlinx-coroutines-swing.jar
    kotlinx-coroutines-test-jvm.jar
    kotlinx-coroutines-test.jar
    slf4j-api.jar

In the .csproj file I have:

  <ItemGroup Condition=" $(TargetFramework.ToLower().StartsWith('monoandroid')) ">
      <Compile Include="Droid\*.cs" />
      <Compile Include="Droid\Specific\*.cs" />
      <ReferenceJar Include="Droid\Jars\*.jar;Droid\Jars\*.aar" />
      <TransformFile Include="Droid\Transforms\*.xml" />
      <LibraryProjectZip Include="Droid\Jars\mcumgr-ble.aar" />
      <!-- t.odo  experiment with EmbeddedReferenceJar -->
      <Reference Include="Mono.Android" />
      <Reference Include="Java.Interop" />
      <PackageReference Include="Karamunting.Kotlin.StdLib" Version="1.3.11" />
      <PackageReference Include="Karamunting.Kotlin.StdLib.Common" Version="1.3.11" />
      <PackageReference Include="Xamarin.KotlinX.Coroutines.Core.Jvm" Version="1.6.4" />
  </ItemGroup>

The depencies of the .csproj look like so:

Dependencies

However I keep getting the following ominous warnings in the build output:

   "/Users/foobar/Repos/xyz.cmps/mcumgr.dev.mcumgr-ble/xyz.McuMgr/xyz.McuMgr.csproj" (default target) (1:19) ->
   "/Users/foobar/Repos/xyz.cmps/mcumgr.dev.mcumgr-ble/xyz.McuMgr/xyz.McuMgr.csproj" (Build target) (1:24) ->
   (_ExportJarToXml target) -> 
     obj/Release/monoandroid12.0/api.xml.class-parse : warning BG8605: The Java type '$' could not be found (are you missing a Java reference jar/aar or a Java binding library NuGet?) [/Users/foobar/Repos/xyz.cmps/mcumgr.dev.mcumgr-ble/xyz.McuMgr/xyz.McuMgr.csproj]
     /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Bindings.ClassParse.targets(36,5): obj/Release/monoandroid12.0/api.xml.class-parse warning BG8605: The Java type '$' could not be found (are you missing a Java reference jar/aar or a Java binding library NuGet?) [/Users/foobar/Repos/xyz.cmps/mcumgr.dev.mcumgr-ble/xyz.McuMgr/xyz.McuMgr.csproj]
     obj/Release/monoandroid12.0/api.xml.class-parse : warning BG8605: The Java type 'io.runtime.mcumgr.exception.McuMgrException' could not be found (are you missing a Java reference jar/aar or a Java binding library NuGet?) [/Users/foobar/Repos/xyz.cmps/mcumgr.dev.mcumgr-ble/xyz.McuMgr/xyz.McuMgr.csproj]
     /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Bindings.ClassParse.targets(36,5): obj/Release/monoandroid12.0/api.xml.class-parse warning BG8605: The Java type 'io.runtime.mcumgr.exception.McuMgrException' could not be found (are you missing a Java reference jar/aar or a Java binding library NuGet?) [/Users/foobar/Repos/xyz.cmps/mcumgr.dev.mcumgr-ble/xyz.McuMgr/xyz.McuMgr.csproj]
     obj/Release/monoandroid12.0/api.xml.class-parse : warning BG8605: The Java type 'kotlin.coroutines.jvm.internal.SuspendLambda' could not be found (are you missing a Java reference jar/aar or a Java binding library NuGet?) [/Users/foobar/Repos/xyz.cmps/mcumgr.dev.mcumgr-ble/xyz.McuMgr/xyz.McuMgr.csproj]
     /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Bindings.ClassParse.targets(36,5): obj/Release/monoandroid12.0/api.xml.class-parse warning BG8605: The Java type 'kotlin.coroutines.jvm.internal.SuspendLambda' could not be found (are you missing a Java reference jar/aar or a Java binding library NuGet?) [/Users/foobar/Repos/xyz.cmps/mcumgr.dev.mcumgr-ble/xyz.McuMgr/xyz.McuMgr.csproj]
     obj/Release/monoandroid12.0/api.xml.class-parse : warning BG8605: The Java type 'no.nordicsemi.android.ble.BleManager' could not be found (are you missing a Java reference jar/aar or a Java binding library NuGet?) [/Users/foobar/Repos/xyz.cmps/mcumgr.dev.mcumgr-ble/xyz.McuMgr/xyz.McuMgr.csproj]
     /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Bindings.ClassParse.targets(36,5): obj/Release/monoandroid12.0/api.xml.class-parse warning BG8605: The Java type 'no.nordicsemi.android.ble.BleManager' could not be found (are you missing a Java reference jar/aar or a Java binding library NuGet?) [/Users/foobar/Repos/xyz.cmps/mcumgr.dev.mcumgr-ble/xyz.McuMgr/xyz.McuMgr.csproj]
     obj/Release/monoandroid12.0/api.xml.class-parse : warning BG8605: The Java type 'no.nordicsemi.android.ble.data.DataMerger' could not be found (are you missing a Java reference jar/aar or a Java binding library NuGet?) [/Users/foobar/Repos/xyz.cmps/mcumgr.dev.mcumgr-ble/xyz.McuMgr/xyz.McuMgr.csproj]
     /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Bindings.ClassParse.targets(36,5): obj/Release/monoandroid12.0/api.xml.class-parse warning BG8605: The Java type 'no.nordicsemi.android.ble.data.DataMerger' could not be found (are you missing a Java reference jar/aar or a Java binding library NuGet?) [/Users/foobar/Repos/xyz.cmps/mcumgr.dev.mcumgr-ble/xyz.McuMgr/xyz.McuMgr.csproj]
     obj/Release/monoandroid12.0/java-resolution-report.log : warning BG8606: Some types or members could not be bound because referenced Java types could not be found. See the 'java-resolution-report.log' file for details. [/Users/foobar/Repos/xyz.cmps/mcumgr.dev.mcumgr-ble/xyz.McuMgr/xyz.McuMgr.csproj]
     /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Bindings.ClassParse.targets(36,5): obj/Release/monoandroid12.0/java-resolution-report.log warning BG8606: Some types or members could not be bound because referenced Java types could not be found. See the 'java-resolution-report.log' file for details. [/Users/foobar/Repos/xyz.cmps/mcumgr.dev.mcumgr-ble/xyz.McuMgr/xyz.McuMgr.csproj]
   
   
   "/Users/foobar/Repos/xyz.cmps/mcumgr.dev.mcumgr-ble/xyz.McuMgr/xyz.McuMgr.csproj" (default target) (1:19) ->
   "/Users/foobar/Repos/xyz.cmps/mcumgr.dev.mcumgr-ble/xyz.McuMgr/xyz.McuMgr.csproj" (Build target) (1:24) ->
   (GenerateBindings target) -> 
     /Users/foobar/Repos/xyz.cmps/mcumgr.dev.mcumgr-ble/xyz.McuMgr/Droid/Transforms/Metadata.xml(10,6): warning BG8A00: Metadata.xml element '<remove-node path="/api/package[@name='no.nordicsemi.android.dfu']/class[@name='DfuBaseService']/implements[contains(@name, 'no.nordicsemi.android.dfu.DfuProgressInfo.ProgressListener')]" />' matched no nodes. [/Users/foobar/Repos/xyz.cmps/mcumgr.dev.mcumgr-ble/xyz.McuMgr/xyz.McuMgr.csproj]
     /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Bindings.Core.targets(61,5): /Users/foobar/Repos/xyz.cmps/mcumgr.dev.mcumgr-ble/xyz.McuMgr/Droid/Transforms/Metadata.xml(10,6) warning BG8A00: Metadata.xml element '<remove-node path="/api/package[@name='no.nordicsemi.android.dfu']/class[@name='DfuBaseService']/implements[contains(@name, 'no.nordicsemi.android.dfu.DfuProgressInfo.ProgressListener')]" />' matched no nodes. [/Users/foobar/Repos/xyz.cmps/mcumgr.dev.mcumgr-ble/xyz.McuMgr/xyz.McuMgr.csproj]
   
       14 Warning(s)
       0 Error(s)

Here is a snippet from ‘api.xml.class-parse’ which is showing the problem at hand:

  <method
    abstract="false"
    deprecated="not deprecated"
    final="false"
    name="addObserver"
    native="false"
    return="void"
    jni-return="V"
    static="false"
    synchronized="true"
    visibility="public"
    bridge="false"
    synthetic="false"
    jni-signature="(Lio/runtime/mcumgr/McuMgrTransport$ConnectionObserver;)V">
    <parameter
      name="observer"
      type="io.runtime.mcumgr.McuMgrTransport.ConnectionObserver"
      jni-type="Lio/runtime/mcumgr/McuMgrTransport$ConnectionObserver;"
      not-null="true" />
  </method>

I suspect that the ‘$’ sign the error is referring to is in method names such as the one shown above:

  io/runtime/mcumgr/McuMgrTransport$ConnectionObserver

Solution

Turns out this is due to the heavy use of Kotlin in the libraries in question. There’s virtually nothing that can be done about this other than creating a wrapper .aar which is purely written in Java and then just create bindings for that (thus side-stepping any and all issues).

Answered By – XDS

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published