Still problems getting java bindings to work as expected

Hi again,

I've yet problems getting java bindings to work, maybe due to my poor java knowledge. Anyway I think documentation can be improved in that.
How do I remove a whole class? Is it possible?

For example, still trying to bind to AdWhirl jar, I found it uses many ad providers' sdk to get it working, but i'll go using only one. For sure, that lib isn't really updated, so it references for example to Google AdSense which have been deprecated and I'm unable to find correct jars from where it was compiled against.

As result I get:

Warning 1 Couldn't load class com/adwhirl/adapters/AdSenseAdapter$ExtendedAdSenseSpec : java.lang.NoClassDefFoundError: com/google/ads/AdSenseSpec
Warning 2 Couldn't load class com/adwhirl/adapters/AdSenseAdapter : java.lang.NoClassDefFoundError: com/google/ads/AdViewListener

Being warnings, and not compile errors I get no namespace or classes shown from .net side, which is useless. So I've noticed those are "adapters" that I'm not going to use... so I think I should safely remove from bindings.

I'm trying this in my Metadata.xml, with no success:

I get:

Warning 10 matched no nodes

Where I'm doing wrong with such rule?

Thank you for any help,
Sq.

Best Answer

Answers

  • GlennWilsonGlennWilson USUniversity ✭✭

    I can't see your rules. Here are some I use for Google AdMob. It is not AdWhirl (which I have never used), but is intended to give you an idea of some of the transforms you can do. Some of these I got from a Xamarin sample, others I added or modified.

    <metadata>
      <!-- I currently only use the package com.google.ads -->
      <remove-node path="/api/package[@name!='com.google.ads']" />
      <!-- Remove deprecated methods and prevent their use and keep build warnings less.  Except I do use SetTesting, so keep it -->
      <remove-node path="/api/package[@name='com.google.ads']/class/method[@deprecated='deprecated' and @name!='setTesting']" />
      <remove-node path="/api/package[@name='com.google.ads']/class[starts-with (@name, 'a')]" />
      <remove-node path="/api/package[@name='com.google.ads']/class[string-length (@name) = 1]" />
      <remove-node path="/api/package[@name='com.google.ads']/class[string-length (@name) = 3 and contains (@name, '.')]" />
      <remove-node path="/api/package[@name='com.google.ads']/class[@name='AdActivity']" />
    </metadata>
    
  • TheSquiffyTheSquiffy ITMember
    edited February 2013

    Thank you for your help.

    unfortunately, I still have no luck :-(

    I must be missing java knowledge: how do I find the correct package name?



    My attempts:

    < remove-node path="/api/package[@name='com.adwhirl.adapters']" / >

    < remove-node path="/api/package[@name='com.adwhirl']" / >

    The warnings are less than before, but for exmaple now I get:

    Warning 1 Couldn't load class com/adwhirl/adapters/AdSenseAdapter$ExtendedAdSenseSpec : java.lang.NoClassDefFoundError: com/google/ads/AdSenseSpec



    What exactly means? Should'nt it have gone? What the "$" sign means?



    Sorry, I feel a bit confused :-(



    Sq.

    EDIT: even with warnings, it gets compiled, but trying to use it don't shows through VS Intellisense.

    ILDASM shows it correctly containing classes and methods:

    http://postimage.org/image/gzaukd7pp/

    What's wrong?

    Thank you,
    Sq.

  • TheSquiffyTheSquiffy ITMember

    Hi,

    Thank you again for your help, I will look for api.xml

    I don't have the missing jars, and I'm not going to use such classes, that's why I was trying to remove from bindings :-/

    Sq.

  • JonathanPryorJonathanPryor USXamarin Team Xamurai

    even with warnings, it gets compiled, but trying to use it don't shows through VS Intellisense.

    You may need to close and re-open the project for IntelliSense to work.

  • TheSquiffyTheSquiffy ITMember
    edited February 2013

    Hi Jonathan,

    sorry, still not working. Even opening the project with Xamarin studio, I can see all the classes in class explorer, but can't see or use as reference. Even compiling, any reference to the bound library don't works.
    The only thing I can see it's a partial class I introduced to get it compiling due to a missing interface not implemented.

    namespace Com.Adwhirl.Obj
    {
      public partial class Ration : global::Java.Lang.Object, global::Java.Lang.IComparable
      {
        public int CompareTo(Java.Lang.Object a)
        {
          return 0;
        }
      }
    }
    

    Sq.

  • TheSquiffyTheSquiffy ITMember
    edited February 2013

    Ok, first of all, thank you both to have forced me to learn and understand a few more from java bindings.

    I made a clean compile (without any partial class) with the following transformations:

    <metadata>
      <attr path="//method[@name='handle']" name="managedName">InvokeHandle</attr>
      <attr path="/api/package[@name='com.adwhirl.obj']/class[@name='Ration']/method[@name='compareTo']/parameter[@name='p0']" name="type">java.lang.Object</attr>
    </metadata>`
    

    Now, here's the situation:

    • I can see all classes and methods through VS and/or xamarin studio objects explorers.
    • I can see all classes and methods with ildasm
    • I can even decompile with dotPeek, again, seeing everything inside
    • There are no obfuscated classess/methods (Adwhirl itself it's open source)

    So, what hell is happening? Why I can't see and use that? :-(

    I insert as usual as reference, both to the .dll file or through project reference directly from within the ides.

    Anyway, I'm still unable to use the produced bound dll with my android project (a simple app).

    Can't find namespace/classes.

    Any clue?

    Sq.

  • TheSquiffyTheSquiffy ITMember

    Ok, I think I've got it.

    The problem happens using Visual Studio 2012.
    Namespace is correctly visible using Visual Studio 2010.

    is it a bug?

    Sq.

  • Severity Code Description Project File Line Suppression State
    Error error: package org.xwalk.core.XWalkUpdater does not exis org.xwalk.core.XWalkUpdater.XWalkBackgroundUpdateListener XwalkAarApp

    Severity Code Description Project File Line Suppression State
    Error error: package org.xwalk.core.XWalkInitializer does not exist
    org.xwalk.core.XWalkInitializer.XWalkInitListener XwalkAarApp

    Am getting these issues after adding latest 23 version aar file how can I rectify...Any help

Sign In or Register to comment.