Ouya libraries do not work with Java2cpp

greeniekingreeniekin Posts: 92Member
edited April 2013 in ODK (OUYA Developer Kit)
I thought I had found a nice simple solution to the ouya ndk problem.
Though I can make it work on any of the android platform jar's I can not make it work with the ouya jar. I do not know why.

If anyone can work it out I would appreciate the help.

If an ouya dev could make some comments about what migh be different about the jar that would be good.

Edit: tried some other jar's(not entended for android) and they work fine.
Post edited by greeniekin on

Comments

  • elecornelecorn Posts: 3Member
    So what is OUYA's plan?  Are they going to provide us with native access to the functionality in those OUYA libs?
  • greeniekingreeniekin Posts: 92Member
    So I opened are the jar deleted all classes. Pasted back just the OuyaController class.
    When I tried to import that jar in it worked.
    So I tried it randomly tried to add some classes back in.

    So far these ones make it crash
    OuyaFacade
    CancelIgnoringOuyaResponseListener
    Product

    These ones work
    GamerIdentity
    OuyaEncreptionHelper
    OuyaErrorCodes
    OuyaInent

    I have not done any-more investigation.
    It may be that the ones that do not work have very complicated method signatures.
    As the current ones that work are really simple just returning or passing integers

    It is amazing that it can work with any android platform jar which is all of the android sdk yet not this the ouya classes.
  • pvernpvern Posts: 2Member
    Dear greeniekin,

    I had the same problems with the java2cpp tool as you describe... however within a totally different context. 

    I finally discovered how to use it the way it is expected to be used. (by building the java2cpp.exe program from the sources, I eventually could trace into the problem via the debugger... and although my build is not yet fully functional I could get enough information to circumvent the issue)

    The hidden secret is that you should include all related types within the (eventual/aggregated) JAR of which you want to generate the C++ code by means of the java2cpp tool.

    So here is the procedure that eventually works.

    Make somewhere on your Windows machine an empty directory; let's call it OUYA-ODK-aggregation.

    Then, into this directory, put the following JARs (please note I use android-17 platform JARs) (origin of the below JARs is the ANDROID SDK and the OUYA SDK):

    + android.jar
    + commons-lang-2.6.jar
    + guava-r09.jar
    + jackson-core-asl-1.8.4.jar
    + jackson-mapper-asl-1.8.4.jar
    + ouya-sdk.jar
    + uiautomator.jar

    (it could be that there is more in the above than strictly needed... don't care)

    The next step is to make an aggregated JAR of the above. To do so, you need the java jar.exe tool which is part of a standard java installation. 

    Below are the instructions (i.e. copy/paste of my cmd.exe terminal window):

    C:\Users\pvern\Desktop\OUYA-ODK-aggregation>jar xf uiautomator.jar

    C:\Users\pvern\Desktop\OUYA-ODK-aggregation>jar xf ouya-sdk.jar

    C:\Users\pvern\Desktop\OUYA-ODK-aggregation>jar xf jackson-mapper-asl-1.8.4.jar

    C:\Users\pvern\Desktop\OUYA-ODK-aggregation>jar xf jackson-core-asl-1.8.4.jar

    C:\Users\pvern\Desktop\OUYA-ODK-aggregation>jar xf guava-r09.jar

    C:\Users\pvern\Desktop\OUYA-ODK-aggregation>jar xf commons-lang-2.6.jar

    C:\Users\pvern\Desktop\OUYA-ODK-aggregation>jar xf android.jar

    C:\Users\pvern\Desktop\OUYA-ODK-aggregation>jar cf aggregated.jar android assets com dalvik java javax junit META-INF org res tv

    C:\Users\pvern\Desktop\OUYA-ODK-aggregation>mkdir aggregated

    C:\Users\pvern\Desktop\OUYA-ODK-aggregation>cd aggregated

    C:\Users\pvern\Desktop\OUYA-ODK-aggregation\aggregated>jar xf ../aggregated.jar

    The final "jar xf ../aggregated.jar" step is there to verify all is ok.

    Now, start the java2cpp.exe program, select the aggregated.jar, and generate the C++ code... and enjoy. My generated C++ output folder eventually has 249 folders, 3.256 files, 38.8 MB.

    Hopes this works at your site as it works here on my site.

    Kind regards,

    pvern.

  • pvernpvern Posts: 2Member
    Dear greeniekin,

    A small but important addition to the above.

    Before doing the "jar cf aggregated.jar android assets com dalvik java javax junit META-INF org res tv" aggregation step in the above, make sure to remove all *.class files out of the OUYA-ODK-aggregation directorytree that end in *$1.class, *$2.class etc... *$15.class... 

    Those are useless to java2cpp, and in fact cause generation of C++ code that won't compile.

    Mygenerated C++ output folder eventually has 249 folders, 3.256 files, 37.5 MB.

    Kind regards,

    pvern.
  • greeniekingreeniekin Posts: 92Member
    Thank you for sharing all this pvern. That will help me and no doubt many others. I can not what to try work this all out myself.
Sign In or Register to comment.