[mono-android] transforming a property in a java library project
Miljenko Cvjetko
mcvjetko at holisticware.net
Tue Jun 26 21:50:12 UTC 2012
Hi
For me some help is:
obj\Debug\api.xml
but in AchartEngine there are no properties, but some internal (that
appear in each class)
api.xml has helped me to see how to build query.
Like Jon said could You show him/us Your project?
I got it!
1. Took your code.
http://pastebin.com/JuBSjkdz
2. Created in eclipse poject..
1. only one java Operations.class
2. Pakaged this into jar with export...
3. fired up VS added JavaBinding project
1. added jar
2. checked properties: InputJar
3. compiled - fine
4. generated code
HolisticWare_JavaBindingProjects\WallyMath\obj\Debug\generated\src\Com.Wally.Math.Operations.cs
5. several properties
1. decided to change prop MultipleItems
Snippet Snippet
[Register ("Multiple_Items")]
public static int MultipleItems {
get {
if (Multiple_Items_jfieldId ==IntPtr.Zero)
Multiple_Items_jfieldId =JNIEnv.GetStaticFieldID (class_ref,"Multiple_Items","I");
return JNIEnv.GetStaticIntField (class_ref, Multiple_Items_jfieldId);
}
set {
if (Multiple_Items_jfieldId ==IntPtr.Zero)
Multiple_Items_jfieldId =JNIEnv.GetStaticFieldID (class_ref,"Multiple_Items","I");
JNIEnv.SetStaticField (class_ref, Multiple_Items_jfieldId,value);
}
}
6. opened up Transforms/Metadata.xml
1. tried property
Snippet
<attr
path="/api/package[@name='com.wally.math']/class[@name='Operations']/property[@name='Multiple_Items']"
name="managedName"
>ThresholdClassAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA</attr>
and method
Snippet
<attr
path="/api/package[@name='com.wally.math']/class[@name='Operations']/method[@name='Multiple_Items']"
name="managedName"
>ThresholdClassAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA</attr>
2.
build is ok, but in Outpu Window You can find:
C:\Program Files\MSBuild\Novell\generator.exe obj\Debug\api.xml
--csdir=obj\Debug\generated\src --enumdir=obj\Debug\generated\enums
--enummetadata=obj\Debug\generated\metadata
--assembly=WallyMath
--ref="C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\mscorlib.dll"
--ref="C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v2.2\Mono.Android.dll"
--ref="C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\mscorlib.dll"
--ref="C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\System.Core.dll"
--ref="C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\System.dll"
--fixup=Transforms\Metadata.xml
--enumfields=Transforms\EnumFields.xml
--enummethods=Transforms\EnumMethods.xml --api-level=8 --global --public (TaskId:27)
BINDINGSGENERATOR : warning :
<attr path="/api/package[@name='com.wally.math']/class[@name='Operations']/method[@name='Multiple_Items']"/>
matched no nodes
3. then open up api.xml + search for something familiar
(attribute from cs file or prop name)
found:
Snippet
<field deprecated="not deprecated" final="false" name="Multiple_Items"
static="true" transient="false" type="int" type-generic-aware="int"
visibility="public" volatile="false">
</field>
4.
instinct told me to try with **field** andMultiple_Items
Snippet<attr
path="/api/package[@name='com.wally.math']/class[@name='Operations']/filed[@name='Multiple_Items']"
name="managedName"
>ThresholdClassAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA</attr>
5.
generated cs file:
Snippet [Register ("Multiple_Items")]
public static int ThresholdClassAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA {
get {
if (Multiple_Items_jfieldId ==IntPtr.Zero)
Multiple_Items_jfieldId =JNIEnv.GetStaticFieldID (class_ref,"Multiple_Items","I");
return JNIEnv.GetStaticIntField (class_ref, Multiple_Items_jfieldId);
}
set {
if (Multiple_Items_jfieldId ==IntPtr.Zero)
Multiple_Items_jfieldId =JNIEnv.GetStaticFieldID (class_ref,"Multiple_Items","I");
JNIEnv.SetStaticField (class_ref, Multiple_Items_jfieldId,value);
}
}
Property changed!
Register is the same
Writeup:
* read output window for
BINDINGSGENERATOR : warning :
<attr path="/api/package[@name='com.wally.math']/class[@name='Operations']/method[@name='Multiple_Items']"/>
matched no nodes
for misspelled words (I wrote filed instead of field - after remake
to make sure - when I wrote this)
* use api.xml to find attributes of what to change! props, fields, methods
HTH
I'm gonna grab a beer and hit the sack
nite
mel
On 2012.06.26 16:49, Wally McClure wrote:
> Mel,
>
> A really dumb question. What am I looking for your charting engine
> project? I see how you have changed an event name, but making the
> suggested change to a method doesn't work for me. Any suggestions are
> appreciated while I labor with my dunce cap on.
> http://en.wikipedia.org/wiki/Dunce_cap
>
> Wally
>
> ------------------------------------------------------------------------
> Date: Tue, 26 Jun 2012 06:50:27 +0200
> From: mcvjetko at holisticware.net
> To: monodroid at lists.ximian.com
> CC: theevilprogrammer at hotmail.com
> Subject: Re: [mono-android] transforming a property in a java library
> project
>
> Hi Wally
>
> On 2012.06.25 22:23, Wally McClure wrote:
>
> As a followup to this, I am getting a bunch of generator.exe
> errors that look like this:
> ------ Build started: Project: BindingLibrary, Configuration:
> Debug Any CPU ------
>
> C:\Program Files
> (x86)\MSBuild\Novell\Xamarin.Android.Bindings.targets(197,5):
> error MSB6006: "generator.exe" exited with code -532462766.
>
> ------ Build started: Project: ExampleJavaBindings, Configuration:
> Debug Any CPU ------
>
> ========== Build: 0 succeeded or up-to-date, 2 failed, 0 skipped
> ==========
>
> something like:
> It seems that xml breaks generator.exe.
> I have filed bug report when there is whietspace in element content:
> <attr
> path="/api/package[@name='org.achartengine.tools']/class[@name='Pan']/method[@name='addPanListener']"
> <mailto:/api/package[@name=%27org.achartengine.tools%27]/class[@name=%27Pan%27]/method[@name=%27addPanListener%27]>
> name="propertyName"
> >
> Panned
> </attr>
>
>
> And now about Your errors - inline
>
> ------------------------------------------------------------------------
> From: theevilprogrammer at hotmail.com
> <mailto:theevilprogrammer at hotmail.com>
> To: monodroid at lists.ximian.com <mailto:monodroid at lists.ximian.com>
> Subject: transforming a property in a java library project
> Date: Mon, 25 Jun 2012 15:51:18 -0400
>
> I have created a class called operations in .java file in
> eclipse. Everything compiles as intended in Eclipse. I want to
> then import my jar file into a java binding project in MfA 4.2. I
> have INTENTIONALLY created a property in java that will result in
> a conflict with an initializer in C#. My question is how do I go
> about fixing this via the transform .xml files?
>
> In the EnumMethods.xml file, I have tried:
> <mapping jni-class="com/scalabledevelopment/math/Operations">
> <method jni-name="Operations" parameter="Operations"
> clr-enum-type="FixedOperations" />
> </mapping>
>
> as will as:
> <mapping jni-class="com/scalabledevelopment/math/Operations">
> <method jni-name="Operations"
> clr-enum-type="FixedOperations" />
> </mapping>
>
>
> It seems it is xml again - from what I can see (blurred) w/o coffee
> this early in the morning.
> You're closing <mapping> twice: with /> and </mapping>...
>
>
> Neither of the above options helps me.
>
> I have tried to go into Metadata.xml and use the following:
> <attr
> path="/api/package[@name='com.scalabledevelopment.math']/class[@name='Operations']/property[@name='Operations']"
> <mailto:/api/package[@name=%27com.scalabledevelopment.math%27]/class[@name=%27Operations%27]/property[@name=%27Operations%27]>
> name="managedName" >NumOperations</attr>
>
>
> And here I think it is not property, but method!
> Props are methods....
>
> try:
>
> <attr
> path="/api/package[@name='com.scalabledevelopment.math']/class[@name='Operations']/method[@name='Operations']"
> <mailto:/api/package[@name=%27com.scalabledevelopment.math%27]/class[@name=%27Operations%27]/method[@name=%27Operations%27]>
> name="managedName" >NumOperations</attr>
>
> see my sample above.... (achartengine wrapped)
> real world (acharengine + admob)
> https://github.com/moljac/HolisticWare_JavaBindingProjects
>
> AdMob is not done (yet)
>
>
> Unfortunately, I have no luck there as well.
>
> My other option is to go into the source file at
> obj/Debug/generated/src/.cs file. I can fix the error there, but
> won't the file be overwritten the next time I perform a compile?
>
> it will - so no use. Don't do it.
>
>
> Ideas, thoughts, and whatever are appreciated.
>
> try commenting/uncommenting metadata.xml in my project. It helped me a
> lot...
>
> regards
>
> mel
>
>
> Wally
>
>
> _______________________________________________
> Monodroid mailing list
> Monodroid at lists.ximian.com <mailto:Monodroid at lists.ximian.com>
>
> UNSUBSCRIBE INFORMATION:
> http://lists.ximian.com/mailman/listinfo/monodroid
>
>
>
> --
> Miljenko Cvjetko dipl.ing. ET
> Direktor/CEO
> Projektant rješenja/Solution Architect
> Razvojni programer/Senior developer
> Voditelj projekta/Project Manager
>
> IX južna obala 13
> Kajzerica Zagreb
> T: 385 1 7775555
> M: 385 91 557 447 3
> F: 385 1 7779556
> e:mcvjetko at holisticware.net <mailto:mcvjetko at holisticware.net>
> w:http://www.holisticware.net
--
Miljenko Cvjetko dipl.ing. ET
Direktor/CEO
Projektant rješenja/Solution Architect
Razvojni programer/Senior developer
Voditelj projekta/Project Manager
IX južna obala 13
Kajzerica Zagreb
T: 385 1 7775555
M: 385 91 557 447 3
F: 385 1 7779556
e: mcvjetko at holisticware.net
w: http://www.holisticware.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/monodroid/attachments/20120626/1604eb0e/attachment-0001.html>
More information about the Monodroid
mailing list