Xamarin - .aar Java 绑定 - 当前上下文中不存在名称“[方法名称]”
Xamarin - .aar Java Binding - The name '[method name]' does not exist in the current context
我正在尝试为 Facebook Notification.aar 库创建绑定。
但是我遇到了编译错误:
Severity Code Description Project File Line Suppression State
Error CS0103 The name 'CreateAsset' does not exist in the current
context FBNotifications C:\Users\jakub\documents\visual studio
2015\Projects\FBNotifications\FBNotifications\obj\Release\generated\src\Com.Facebook.Notifications.Internal.Asset.Handlers.BitmapAssetHandler.cs 344 Active
Severity Code Description Project File Line Suppression State
Error CS0103 The name 'CreateView' does not exist in the current
context FBNotifications C:\Users\jakub\documents\visual studio
2015\Projects\FBNotifications\FBNotifications\obj\Release\generated\src\Com.Facebook.Notifications.Internal.Asset.Handlers.BitmapAssetHandler.cs 350 Active
有问题的方法如下:
// This method is explicitly implemented as a member of an instantiated Com.Facebook.Notifications.Internal.Asset.AssetManager.IAssetHandler
global::Java.Lang.Object global::Com.Facebook.Notifications.Internal.Asset.AssetManager.IAssetHandler.CreateAsset (global::Org.Json.JSONObject p0, global::Com.Facebook.Notifications.Internal.Asset.AssetManager.IAssetCache p1)
{
return global::Java.Interop.JavaObjectExtensions.JavaCast<Java.Lang.Object>(CreateAsset (p0, p1));
}
// This method is explicitly implemented as a member of an instantiated Com.Facebook.Notifications.Internal.Asset.AssetManager.IAssetHandler
global::Android.Views.View global::Com.Facebook.Notifications.Internal.Asset.AssetManager.IAssetHandler.CreateView (global::Java.Lang.Object p0, global::Android.Content.Context p1)
{
return CreateView (global::Java.Interop.JavaObjectExtensions.JavaCast<global::Com.Facebook.Notifications.Internal.Asset.Handlers.BitmapAssetHandler.BitmapAsset>(p0), p1);
}
我看到代码问题可以这样解决:
// This method is explicitly implemented as a member of an instantiated Com.Facebook.Notifications.Internal.Asset.AssetManager.IAssetHandler
global::Java.Lang.Object global::Com.Facebook.Notifications.Internal.Asset.AssetManager.IAssetHandler.CreateAsset (global::Org.Json.JSONObject p0, global::Com.Facebook.Notifications.Internal.Asset.AssetManager.IAssetCache p1)
{
return global::Java.Interop.JavaObjectExtensions.JavaCast<Java.Lang.Object>(((AssetManager.IAssetHandler)this).CreateAsset (p0, p1));
}
// This method is explicitly implemented as a member of an instantiated Com.Facebook.Notifications.Internal.Asset.AssetManager.IAssetHandler
global::Android.Views.View global::Com.Facebook.Notifications.Internal.Asset.AssetManager.IAssetHandler.CreateView (global::Java.Lang.Object p0, global::Android.Content.Context p1)
{
return ((AssetManager.IAssetHandler)this).CreateView (global::Java.Interop.JavaObjectExtensions.JavaCast<global::Com.Facebook.Notifications.Internal.Asset.Handlers.BitmapAssetHandler.BitmapAsset>(p0), p1);
}
我认为为 BitmapAssetHandler 创建部分 class 并将更正的方法放在那里,同时在 Metadata.xml 中删除它会修复它,但它没有'好像不是。
<remove-node path="/api/package[@name='com.facebook.notifications.internal.asset.handlers']/class[@name='BitmapAssetHandler']/method[@name='CreateAsset']" />
<remove-node path="/api/package[@name='com.facebook.notifications.internal.asset.handlers']/class[@name='BitmapAssetHandler']/method[@name='CreateView']" />
如果我这样做,我会收到错误消息,指出这些方法存在两次(它们不会以某种方式从生成的代码中删除)。我希望这不是一个太复杂的问题。我的方法正确吗?或者是否需要做其他事情才能使其正常工作。
删除节点 元素就可以了。
<remove-node path="/api/package[@name='com.facebook.notifications.internal.asset.handlers']/class[@name='BitmapAssetHandler']" />
我正在尝试为 Facebook Notification.aar 库创建绑定。
但是我遇到了编译错误:
Severity Code Description Project File Line Suppression State Error CS0103 The name 'CreateAsset' does not exist in the current context FBNotifications C:\Users\jakub\documents\visual studio 2015\Projects\FBNotifications\FBNotifications\obj\Release\generated\src\Com.Facebook.Notifications.Internal.Asset.Handlers.BitmapAssetHandler.cs 344 Active
Severity Code Description Project File Line Suppression State Error CS0103 The name 'CreateView' does not exist in the current context FBNotifications C:\Users\jakub\documents\visual studio 2015\Projects\FBNotifications\FBNotifications\obj\Release\generated\src\Com.Facebook.Notifications.Internal.Asset.Handlers.BitmapAssetHandler.cs 350 Active
有问题的方法如下:
// This method is explicitly implemented as a member of an instantiated Com.Facebook.Notifications.Internal.Asset.AssetManager.IAssetHandler
global::Java.Lang.Object global::Com.Facebook.Notifications.Internal.Asset.AssetManager.IAssetHandler.CreateAsset (global::Org.Json.JSONObject p0, global::Com.Facebook.Notifications.Internal.Asset.AssetManager.IAssetCache p1)
{
return global::Java.Interop.JavaObjectExtensions.JavaCast<Java.Lang.Object>(CreateAsset (p0, p1));
}
// This method is explicitly implemented as a member of an instantiated Com.Facebook.Notifications.Internal.Asset.AssetManager.IAssetHandler
global::Android.Views.View global::Com.Facebook.Notifications.Internal.Asset.AssetManager.IAssetHandler.CreateView (global::Java.Lang.Object p0, global::Android.Content.Context p1)
{
return CreateView (global::Java.Interop.JavaObjectExtensions.JavaCast<global::Com.Facebook.Notifications.Internal.Asset.Handlers.BitmapAssetHandler.BitmapAsset>(p0), p1);
}
我看到代码问题可以这样解决:
// This method is explicitly implemented as a member of an instantiated Com.Facebook.Notifications.Internal.Asset.AssetManager.IAssetHandler
global::Java.Lang.Object global::Com.Facebook.Notifications.Internal.Asset.AssetManager.IAssetHandler.CreateAsset (global::Org.Json.JSONObject p0, global::Com.Facebook.Notifications.Internal.Asset.AssetManager.IAssetCache p1)
{
return global::Java.Interop.JavaObjectExtensions.JavaCast<Java.Lang.Object>(((AssetManager.IAssetHandler)this).CreateAsset (p0, p1));
}
// This method is explicitly implemented as a member of an instantiated Com.Facebook.Notifications.Internal.Asset.AssetManager.IAssetHandler
global::Android.Views.View global::Com.Facebook.Notifications.Internal.Asset.AssetManager.IAssetHandler.CreateView (global::Java.Lang.Object p0, global::Android.Content.Context p1)
{
return ((AssetManager.IAssetHandler)this).CreateView (global::Java.Interop.JavaObjectExtensions.JavaCast<global::Com.Facebook.Notifications.Internal.Asset.Handlers.BitmapAssetHandler.BitmapAsset>(p0), p1);
}
我认为为 BitmapAssetHandler 创建部分 class 并将更正的方法放在那里,同时在 Metadata.xml 中删除它会修复它,但它没有'好像不是。
<remove-node path="/api/package[@name='com.facebook.notifications.internal.asset.handlers']/class[@name='BitmapAssetHandler']/method[@name='CreateAsset']" />
<remove-node path="/api/package[@name='com.facebook.notifications.internal.asset.handlers']/class[@name='BitmapAssetHandler']/method[@name='CreateView']" />
如果我这样做,我会收到错误消息,指出这些方法存在两次(它们不会以某种方式从生成的代码中删除)。我希望这不是一个太复杂的问题。我的方法正确吗?或者是否需要做其他事情才能使其正常工作。
删除节点 元素就可以了。
<remove-node path="/api/package[@name='com.facebook.notifications.internal.asset.handlers']/class[@name='BitmapAssetHandler']" />