【问题标题】:Xamarin Android Native binding for Android Plugin SDK用于 Android 插件 SDK 的 Xamarin Android 本机绑定
【发布时间】:2022-11-12 13:32:48
【问题描述】:

我正在尝试为原生 Android 内置的插件 SDK(使用 kotlin 语言构建)创建 xamarin 包装器。 我正在低于日志。

obj/Debug/api.xml.class-parse:警告 BG8605:找不到 Java 类型“$”(您是否缺少 Java 引用 jar/aar 或 Java 绑定库 NuGet?)

/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Bindings.ClassParse.targets(36,5): obj/Debug/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?)

obj/Debug/api.xml.class-parse : warning BG8605: The Java type 'kotlin.jvm.internal.FunctionReferenceImpl' could not be found (are you missing a Java reference jar/aar or a Java binding library NuGet?)
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Bindings.ClassParse.targets(36,5): obj/Debug/api.xml.class-parse warning BG8605: The Java type 'kotlin.jvm.internal.FunctionReferenceImpl' could not be found (are you missing a Java reference jar/aar or a Java binding library NuGet?)

The method '[Method] com.*.blesdk.manager.BluetoothLeService access$getMBluetoothLeService$p(com.*.blesdk.manager.BLEConnectionManager $this)' was removed because its name contains a dollar sign.
The method '[Method] java.lang.String access$getMDeviceAddress$p(com.*.blesdk.manager.BLEConnectionManager $this)' was removed because its name contains a dollar sign.
The method '[Method] com.*.blesdk.manager.BLEConnectionManager.BLEConnectionListener access$getUser$p(com.*.blesdk.manager.BLEConnectionManager $this)' was removed because its name contains a dollar sign.
The method '[Method] void access$setMBluetoothLeService$p(com.*.blesdk.manager.BLEConnectionManager $this, com.*.blesdk.manager.BluetoothLeService <set-?>)' was removed because its name contains a dollar sign.
The method '[Method] boolean connectDevice$default(com.*.blesdk.manager.BLEConnectionManager p0, java.lang.String p1, int p2, java.lang.Object p3)' was removed because its name contains a dollar sign.
The class '[Class] com.*.blesdk.manager.BLEConnectionManager.Companion.1' was removed because the Java base type 'kotlin.jvm.internal.FunctionReferenceImpl' could not be found.
The class '[Class] com.*.blesdk.manager.BLEScanManager.Companion.1' was removed because the Java base type 'kotlin.jvm.internal.FunctionReferenceImpl' could not be found.
The method '[Method] void access$broadcastUpdate(com.*.blesdk.manager.BluetoothLeService $this, java.lang.String action)' was removed because its name contains a dollar sign.
The method '[Method] void access$broadcastUpdate(com.*.blesdk.manager.BluetoothLeService $this, java.lang.String action, android.bluetooth.BluetoothGattCharacteristic characteristic)' was removed because its name contains a dollar sign.
The method '[Method] android.bluetooth.BluetoothGatt access$getMBluetoothGatt$p(com.*.blesdk.manager.BluetoothLeService $this)' was removed because its name contains a dollar sign.
The method '[Method] java.lang.String access$getTAG$cp()' was removed because its name contains a dollar sign.
The method '[Method] java.util.UUID access$getUUID_HEART_RATE_MEASUREMENT$cp()' was removed because its name contains a dollar sign.
The method '[Method] void access$setMConnectionState$p(com.*.blesdk.manager.BluetoothLeService $this, int <set-?>)' was removed because its name contains a dollar sign.
The method '[Method] void logd$default(com.*.blesdk.utility.Loggers p0, java.lang.String p1, java.lang.Throwable p2, int p3, java.lang.Object p4)' was removed because its name contains a dollar sign.
The method '[Method] void loge$default(com.*.blesdk.utility.Loggers p0, java.lang.String p1, java.lang.Throwable p2, int p3, java.lang.Object p4)' was removed because its name contains a dollar sign.
The method '[Method] void logi$default(com.*.blesdk.utility.Loggers p0, java.lang.String p1, java.lang.Throwable p2, int p3, java.lang.Object p4)' was removed because its name contains a dollar sign.
The method '[Method] void logv$default(com.*.blesdk.utility.Loggers p0, java.lang.String p1, java.lang.Throwable p2, int p3, java.lang.Object p4)' was removed because its name contains a dollar sign.
The method '[Method] void logw$default(com.*.blesdk.utility.Loggers p0, java.lang.String p1, java.lang.Throwable p2, int p3, java.lang.Object p4)' was removed because its name contains a dollar sign.

obj/Debug/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.
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Bindings.ClassParse.targets(36,5): obj/Debug/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.

【问题讨论】:

  • 根据错误信息,您可以see the "java-resolution-report.log" file

标签: xamarin xamarin-binding xamarin-native


【解决方案1】:

您在初始阶段遇到的错误爪哇类型解析作为警告发出。这些缺少外部爪哇类型,通常表明用户缺少引用 .jar 或绑定NuGet.

The class '[Class] com.*.blesdk.manager.BLEConnectionManager.Companion.1' was removed because the Java base type 'kotlin.jvm.internal.FunctionReferenceImpl' could not be found.
The class '[Class] com.*.blesdk.manager.BLEScanManager.Companion.1' was removed because the Java base type 'kotlin.jvm.internal.FunctionReferenceImpl' could not be found.

剩余的分辨率错误通常是那些缺少外部类型的后果。例如:'androidx.appcompat.widget.AppCompatTextView',如果上面的缺失类型导致我们删除com.example.MyTextView,那么可能导致我们因为缺失而删除类GetMyTextView()返回类型。

建议仔细检查java-resolution-report.log,它会显示警告,通知用户某些类型无法绑定。

因为我注意到这个问题有不同的变体并且导致你可以改变类的可访问性给定以下科特林代码:

internal Class {
  public interface { }
}

// The default Java representation 
public Class {
  public interface { }
}

// In order to prevent this being bound, our Kotlin fixups instead change it to
private Class {
  private interface { }
}

这可能会帮助您消除或减少警告,因为您必须在日志文件中的类和方法之间导航。


还要检查:

【讨论】:

  • 嗨@elihe-blaster,感谢您解释这个问题。您能否参考任何示例来解决此问题。
猜你喜欢
  • 1970-01-01
  • 2020-07-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多