Xamarin binding of Android library(AAR) - xamarin.android

I want to use https://www.dsphotoeditor.com/ library in xamarin Android. For that I have created a binding project. I know how to create binding, I have already do it for sinch library. But for https://www.dsphotoeditor.com/, I am not able to solve some error. I have updated its metdata.xml file with following content
<attr path="/api/package[#name='com.dsphotoeditor.sdk.ui.focusablelinearlayout']" name="managedName">BindingFocusablelinearlayout</attr>
<attr path="/api/package[#name='com.dsphotoeditor.sdk.ui.imagebrushview']" name="managedName">BindingImagebrushview</attr>
<attr path="/api/package[#name='com.dsphotoeditor.sdk.ui.stickerview']" name="managedName">BindingStickerview</attr>
<attr path="/api/package[#name='com.dsphotoeditor.sdk.ui.touchimageview']" name="managedName">BindingTouchimageview</attr>
<attr path="/api/package[#name='com.dsphotoeditor.sdk.ui.touchimageview']/class[#name='TouchImageView']/method[#name='onConfigurationChanged' and count(parameter)=1 and parameter[1][#type='android.content.res.Configuration']]" name="visibility">protected</attr>
<attr path="/api/package[#name='com.dsphotoeditor.sdk.ui.touchimageview']/class[#name='TouchImageView']/method[#name='onRestoreInstanceState' and count(parameter)=1 and parameter[1][#type='android.os.Parcelable']]" name="visibility">protected</attr>
<attr path="/api/package[#name='com.dsphotoeditor.sdk.ui.touchimageview']/class[#name='TouchImageView']/method[#name='onSaveInstanceState' and count(parameter)=0]" name="visibility">protected</attr>
<attr path="/api/package[#name='com.dsphotoeditor.sdk.ui.simplecropview']/class[#name='CropImageView']/method[#name='onDraw' and count(parameter)=1 and parameter[1][#type='android.graphics.Canvas']]" name="visibility">protected</attr>
<attr path="/api/package[#name='com.dsphotoeditor.sdk.ui.simplecropview']/class[#name='CropImageView']/method[#name='onRestoreInstanceState' and count(parameter)=1 and parameter[1][#type='android.os.Parcelable']]" name="visibility">protected</attr>
<attr path="/api/package[#name='com.dsphotoeditor.sdk.ui.simplecropview']/class[#name='CropImageView']/method[#name='onSaveInstanceState' and count(parameter)=0]" name="visibility">protected</attr>
First to 4th line in above mentioned XML is added because to remove error
"Namespace path cannot have classname. Name voilation error"
5th to 10th lines added to make class protected(Reason:By default .Net making public classes so it cause issues in overriding java protected methods)
Above method metadata helps to fix some error but it still have many error .Error are given below
Class BindingImagebrushview.ImageBrushView has unknown base type
com.dsphotoeditor.sdk.ui.a.c.
Unknown return type com.dsphotoeditor.sdk.ui.simplecropview.a in
method A in managed type
Com.Dsphotoeditor.Sdk.UI.Simplecropview.CropImageView.
Unknown parameter type com.dsphotoeditor.sdk.ui.simplecropview.b.b in method A in managed
type Com.Dsphotoeditor.Sdk.UI.Simplecropview.CropImageView.
Unknown parameter type
com.dsphotoeditor.sdk.ui.simplecropview.CropImageView.a in method A in
managed type Com.Dsphotoeditor.Sdk.UI.Simplecropview.CropImageView.
Unknown parameter type
com.dsphotoeditor.sdk.ui.simplecropview.CropImageView.a in method
SetCropMode in managed type
Com.Dsphotoeditor.Sdk.UI.Simplecropview.CropImageView.
Unknown parameter type
com.dsphotoeditor.sdk.ui.simplecropview.CropImageView.c in method
SetGuideShowMode in managed type
Com.Dsphotoeditor.Sdk.UI.Simplecropview.CropImageView.
Unknown parameter type com.dsphotoeditor.sdk.ui.simplecropview.CropImageView.c in method
SetHandleShowMode in managed type
Com.Dsphotoeditor.Sdk.UI.Simplecropview.CropImageView.
Working Android code of this library https://drive.google.com/open?id=1msStp0MdaGVY8QVXl8ZVpzLrqXoJQoMG

Related

Spring.net ContextRegistry.GetContext fails with 2 interface implementations

I have a .net application, that uses Spring.net.
Also there are 2 implementations of one interface. Which one should be used - it is based on configuration file.
The bootstrap for Spring has
<objects>
<object id="Impl1" name="Impl1" type="namespace.Impl1, IInterface" >
</object>
<object id="Impl2" name="Impl2" type="namespace.Impl2, IInterface" >
</object>
</objects>
It fails on
var appContext = ContextRegistry.GetContext();
The error message is:
An unhandled exception of type
'System.Configuration.ConfigurationErrorsException' occurred in
Spring.Core.dll
Additional information: Unsatisfied dependency expressed through
constructor argument with index 2 of type [namespace.IInterface] : No
unique object of type [namespace.IInterface] is defined : expected
single matching object but found 2:
System.Collections.Specialized.OrderedDictionary
I found another configuration, where autowire setting was set as autodetect.
<object id="workspaceExportService" type="namespace.Imp3, Namespace"
autowire="autodetect" />
This class Imp3 has a constructor with IInterface parameter. So, It tries to resolve the implementation of IInterface, but find two of them.
As a solution, you can add lazy-init="true" attribute to object node.

NineOldAndroids for MonoDroid

I am trying to use NineOldAndroids to enable backwards compatibility with pre-3.x devices, but I am encountering the following build error:
.../NineOldAndroids/obj/Debug/generated/src/Com.Nineoldandroids.Animation.AnimatorSet.cs(83,83):
Error CS0508:
Com.Nineoldandroids.Animation.AnimatorSet.SetDuration(long)': return
type must beCom.Nineoldandroids.Animation.Animator' to match
overridden member
`Com.Nineoldandroids.Animation.Animator.SetDuration(long)' (CS0508)
(NineOldAndroids)
but the signature in generated code looks like this:
public override global::Com.Nineoldandroids.Animation.AnimatorSet SetDuration (long p0)
and the class signature of AnimatorSet looks like this:
public sealed partial class AnimatorSet : global::Com.Nineoldandroids.Animation.Animator {
The problem is, since AnimatorSet is inherited from Animator, I'm not sure why it should be a problem.
Are there any examples of binding NineOldAndroids for MonoDroid that you're aware of or know how to fix this?
These error messages are because C# doesn't support Covariant Return Types while Java ≥1.5 does.
Add these lines to Transforms/Metadata.xml:
<attr path="/api/package/class[#name='AnimatorSet']/method[#name='setDuration']" name="managedReturn">Com.Nineoldandroids.Animation.Animator</attr>
<attr path="/api/package/class[#name='ValueAnimator']/method[#name='setDuration']" name="managedReturn">Com.Nineoldandroids.Animation.Animator</attr>

Monodroid binding change variable name

I try to bind BugSense 3.0.5 to MonoDroid. I create a new Java Binding Library project, add the bugsense3.0.5.jar to the Jars-folder. I build it, and get the following error:
'Crash': member names cannot be the same as their enclosing type
The auto generate code:
[global::Android.Runtime.Register ("com/bugsense/trace/models/Crash", DoNotGenerateAcw=true)]
public partial class Crash : global::Java.Lang.Object, global::Java.IO.ISerializable {
[Register ("CRASH")]
public const int Crash = (int) 1;
So I need to rename the global variable "Crash" in the Metadata.xml- but how do I do that?
I have try:
<attr path="/api/package[#name='com.bugsense.trace.models']/class[#name='Crash']/field[#name='Crash']" name="managedName">mCrash</attr>
But it fails: matched no nodes
Fixed it renaming the class instead
<attr path="/api/package[#name='com.bugsense.trace.models']/class[#name='Crash']]" name="managedName">Crashed</attr>
You should always look for original fields name in java.
As i know it is lowerCamelCase. And it is probably hidden into setter/getter so you should search for /method[#name='getCrash']

WPF Data Binding an Enum

The public enum 'StocksGroupType' is in the namespace 'EquityTrades'.
Before the code at the base of this email, I have the code line:
xmlns:EquityTrades="clr-namespace:EquityTrades;assembly=EquityTrades"
The code fails to identify the 'StocksGroupType' enum at the line with:
It returns the error: "Type reference cannot find type named '{http://schemas.microsoft.com/winfx/2006/xaml/presentation}EquityTrades.StocksGroupType'."
I've tried deleting the ';assembly=EquityTrades', and other variations, according to what I've found on the internet. Nothing seems to work. Please help. I'm using VS2010.
<Window.Resources>
<ObjectDataProvider x:Key="stocksGroupTypeName" MethodName="GetValues" ObjectType="{x:Type System:Enum}">
<ObjectDataProvider.MethodParameters>
<x:Type TypeName="EquityTrades.StocksGroupType" />
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
</Window.Resources>
The following line is wrong.
<x:Type TypeName="EquityTrades.StocksGroupType" />
You have to change TypeName value from EquityTrades.StocksGroupType to EquityTrades:StocksGroupType.

AXIS 1.4 adds elements to custom fault type

Maybe someone found a workaround for the following problem:
It seems as if AXIS 1.4 adds an <exceptionName> and a <hostname> element to each custom fault element. In the WSDL the fault is defined to only consist of a custom fault message systemMessage.
This is the answer returned from my service. Never mind about the error, it could be any error that is returned as a fault.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<soapenv:Fault>
<faultcode>soapenv:Server.generalException</faultcode>
<faultstring/>
<detail>
<ns1:systemMessage xmlns:ns1="http://my.domain/workflow/engine/wsdl/types">
<message>nullcvc-datatype-valid.1.2.1: '2008-12-02T00:00:00' is not a valid value for 'date'.cvc-type.3.1.3</message>
<code>XML string is not valid</code>
<parameter/>
</ns1:systemMessage>
<ns2:exceptionName xmlns:ns2="http://xml.apache.org/axis/">com.domain.commons.ws.schema.SystemMessageType</ns2:exceptionName>
<ns3:hostname xmlns:ns4="http://xml.apache.org/axis/">my.host.com</ns3:hostname>
</detail>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
It seems as if this is an error in Axis 1.4. Does anyone know a workaround for this behaviour?
There's a workaround for the problem:
In the AXIS generated fault class that extends from org.apache.axis.AxisFault alter the constructors as follows in order to suppress the elements (below is the fault class that is used for the fault returned in the question):
public SystemMessageType() {
// Suppress the two elements
this.removeHostname();
this.removeFaultDetail(org.apache.axis.Constants.QNAME_FAULTDETAIL_EXCEPTIONNAME);
}
public SystemMessageType(
java.lang.String message1,
java.lang.String code,
java.lang.String[] parameter) {
// Call the default constructor
this();
this.message1 = message1;
this.code = code;
this.parameter = parameter;
}
This workaround solves the problem. Nevertheless, whenever you regenerate your code for the SOAP web service you have to adapt the fault class.

Resources