Closed just4phil closed 9 years ago
How exactly did you do this? Looks like you just don't have the dependent libs in your build path. Ouya-SDK and the open-iab jars.
You need to place the gdx-pay-android-openiab.jar and gdx-pay-android-ouya.jar into your project as well to get this to work. What exact error message are you getting?
@Tom-Ski , @noblemaster i forked the gdx-pay-repo and cloned it to my local pc then i gradle-imported the projects into my actual game then i removed all my former integrated gdx-pay-stuff and added the new gdx-pay-projects to the build-path of the android-project and the core-project the OUYA-sdk.jar is in place..... but why do i need gdx-pay-android-openiab.jar and gdx-pay-android-ouya.jar when i have the sources? and where do i get them?
Because those projects depend on the ouya-sdk and openiab.jar.
Don't add to build path if you have imported via gradle, add it with Gradle, then it will link up dependencies correctly.
If you don't want to do that, you have to manually add the jars to your build path from the projects/lib folders. This is because these jars are hooked up with Gradle, by adding projects to the build path in the eclipse way, you are ignoring everything that Gradle has hooked up correctly in those projects.
Sorry..... maybe I'm blind but where do I get those jars or must I rename ouya-sdk.jar and openIAB.jar???
You reference those jars.
why do i need gdx-pay-android-openiab.jar and gdx-pay-android-ouya.jar when i have the sources?
In that case you will need to add ouya-sdk.jar and openiab.jar only.
maybe I'm blind but where do I get those jars
gdx-pay-android-openiab.jar and gdx-pay-android-ouya.jar where built when gdx-pay was still within the libGDX project as an extension. Now that gdx-pay is in a separate repo, they will need to be built from sources. We should add a "dist" task to gradle. @MobiDevelop has promised to set it up but I guess he didn't have time to get to it yet. Also, it would be nice to have nightlies and release builds for those jars and upload them somewhere.
I don't really think there needs to be a zip distribution. If you guys do, feel free to create a "dist" task.
All the artifacts are being published to Sonatype.
I don't really think there needs to be a zip distribution. If you guys do, feel free to create a "dist" task.
I thought you were going to do that? I definitely agree that maven makes sense for use libgdx/gdx-pay/etc. developers. Thanks for setting that up! :) However for users/app developers using maven seems little bit overkill. Especially if you still have to add the ouya-sdk.jar etc. by hand anyway. There is a ZIP distribution for libgdx which I think is great. I actually added building of the gdx-pay-*.jars in there. Now that gdx-pay is in a separate repo, that won't work anymore. I guess I'll just have to do it again for gdx-pay unless someone else is coming forward...
Overkill? The majority of libgdx users are using Gradle already.
All they have to do is add the dependency to their build.gradle. If they target ouya there is the extra step of adding the jar they should have downloaded when they became an ouya developer. Then add a couple permissions to their manifest.
@noblemaster, @Tom-Ski ok guys, i tried it again:
now i dont get any crashes anymore, BUT the purchaseManager is == null .... i debugged a bit and it seems that the reflection code doesnt work as expected (at least on ouya)
can someone tell me how exactly it should work and in what order? it seems confusing....
by the way: it works when i manually set the manager: PurchaseSystem.setManager(new PurchaseManagerAndroidOUYA(androidApplication, 0));
Are you using proguard when deploying to your device? Some classes, i.e. IAP.java might have been removed by proguard because proguard thought they weren't needed?
Anyhow, could you also post your log output?
i dont use proguard.
here is the log:
10-13 21:02:08.533: I/(1289): Loaded EGL implementation /system/lib//egl/libEGL_tegra_impl
10-13 21:02:08.533: D/libEGL(1289): loaded /system/lib/egl/libGLESv1_CM_tegra.so
10-13 21:02:08.533: D/libEGL(1289): loaded /system/lib/egl/libGLESv2_tegra.so
10-13 21:02:08.563: E/dalvikvm(1289): Could not find class 'com.badlogic.gdx.pay.android.ouya.PurchaseManagerAndroidOUYA', referenced from method de.philweb.game2.android.OUYAResolver.
right now i have a second problem: i always get: "Conversion to Dalvik format failed with error 1" i dont see any reason for this.... i already tried different solutions (new repo, restart eclipse, clean/build, ..) but nothing helped.... when i delete "private libraries" in eclipse build path it works.... but is that a good idea??? has anyone any suggestion?
[2014-10-13 23:16:31 - game2-android] Dx trouble processing "java/util/EventListenerProxy.class":
Ill-advised or mistaken usage of a core class (java.* or javax.*) when not building a core library.
This is often due to inadvertently including a core library file in your application's project, when using an IDE (such as Eclipse). If you are sure you're not intentionally defining a core class, then this is the most likely explanation of what's going on.
[...]
[2014-10-13 23:16:31 - game2-android] Dx 1 error; aborting [2014-10-13 23:16:31 - game2-android] Conversion to Dalvik format failed with error 1
Thanks for the log output!
Could not find method com.badlogic.gdx.pay.PurchaseSystem.hasManager, referenced from method de.philweb.game2.android.OUYAResolver.requestPurchase
That seems pretty odd given you included it. I wonder: did you include all the gdx-pay projects as Android libraries as well? I think just adding them to your build path only might not work for Android? In any case, go into project settings and under "Android" (above the "Java Build Path") add all the projects as libraries. Does that work?
The majority of libgdx users are using Gradle already.
Not sure where you got your numbers from? Seems that all the people that posted would prefer jars which seems odd given that the "majority" is using Gradle. The big libgdx-motherproject doesn't contain Gradle either. And providing a bunch of task-less gradle files for each of the projects doesn't help getting your point over either. At least a dist task as it is provided in libgdx setup would have been nice :)
I'm talking about libgdx users. People using libgdx as a library, not people working on libgdx itself.
The gradle files build and publish the artifacts. They have the tasks needed to accomplish that goal. Users are not supposed to download and use these projects... the average user will add the dependency to their project, add a couple manifest entries and be on with their business.
@noblemaster i tried adding the projects as libraries ("add class folders").... but then eclipse says: Build path contains duplicate entry:...openiab' for project 'game2-android' when i remove the projects from the projects tab... then the classes cant be resolved anymore.... it sucks .....
That's the wrong place. I assume you are using Eclipse? On the very left side of the properties window for your project there is the "Java Build Path" that you have selected. Instead, select "Android" a few list items above "Java Build Path". In there, on the bottom of the right hand side there is a checkbox called "Is Android Library". Don't select that, but underneath, add the gdx-pay projects using the "Add..." button! You might have to make those gdx-pay projects library projects first before you can add them? I wonder? I haven't setup the gdx-pay repo so I am not sure if that was done?
The are not set up as Android library projects. They don't need to be.
Here's what I did to use the gdx-pay repo via Gradle, with normal Eclipse projects (this is not really a recommended approach, but it works fine).
THX! Will try that this evening.... Am 15.10.2014 06:54 schrieb "Justin Shapcott" notifications@github.com:
Here's what I did to use the gdx-pay repo via Gradle, with normal Eclipse projects (this is not really a recommended approach, but it works fine).
- Gradle import the gdx-pay projects into your workspace.
- Add a reference to the main gdx-pay project to your core project.
- Add a reference to the gdx-pay-android (plus openiab and/or ouya variants) to your android project.
- Add a reference to the openiab jar (get the path from the openiab project Gradle Dependencies) to your android project
- Add a reference to the ouya jar (from ouya project lib directory) to your android project
- Add whatever permissions you need for the stores you are targeting to your AndroidManifest.xml
— Reply to this email directly or view it on GitHub https://github.com/libgdx/gdx-pay/issues/2#issuecomment-59157622.
@MobiDevelop ....Add a reference to the main gdx-pay project to your core project.....
sigh* when i go in eclipse to build path -> source -> link source and add the reference to the gdx-pay project then i get the eclipse error: The declared package "com.badlogic.gdx.pay" does not match the expected package "src.com.badlogic.gdx.pay"
the same happens with all references in all projects ....
Don't do linked source, add a project reference.
ok.... now i have no errors.... but still running on my ouya doesnt work:
10-15 18:52:50.424: E/AndroidRuntime(1513): FATAL EXCEPTION: main
10-15 18:52:50.424: E/AndroidRuntime(1513): java.lang.NoClassDefFoundError: com.badlogic.gdx.pay.android.ouya.PurchaseManagerAndroidOUYA
10-15 18:52:50.424: E/AndroidRuntime(1513): at de.philweb.game2.android.OUYAResolver.
Are you exporting everything you need? Check your Order and Export tab in Build Path settings of your android project.
yeah .... it works a bit..... at least the game starts :) BUT.... still not purchaseManagerOUYA available! (== null) so....after all this mess.... i guess that the reflection part for the ouya-purchasemanager maybe doesnt work?
I just tried on my Ouya... It worked for me after I fixed a bug in PurchaseManagerAndroidOUYA.
This bug was not related to the reflection, however.
OK...what was the Problem? Did you commit the fix? Am 16.10.2014 06:33 schrieb "Justin Shapcott" notifications@github.com:
I just tried on my Ouya... It worked for me after I fixed a bug in PurchaseManagerAndroidOUYA.
— Reply to this email directly or view it on GitHub https://github.com/libgdx/gdx-pay/issues/2#issuecomment-59312959.
No, I haven't committed the fix yet. The problem is you are creating a handler on the GL Thread, which hasn't called Looper.prepare().
Ok....i can check that this evening.... THX!
There is another problem though, the Ouya purchase manager only works once - if you exit and come back without the process being killed, it cannot create the purchase manager the second time.
@MobiDevelop Hmmm but even when there is no looper the manager object should not be null....?!
No clue how you got a null purchase manager.
By the way, the "only works once" problem is not exclusive to the Ouya purchase manager. The same behavior exists for the OpenIAB version too.
To exit properly, PurchaseSystem.dispose() has to be called. It's in the test.
By the way, shouldn't the gdx-pay-tests-android project be setup as an Android project? It's not actually a Desktop project.
Yes, it is the dispose call that makes it not work the second time around.
Yes, gdx-pay-tests-android is set up as an Android project.
Yes, gdx-pay-tests-android is set up as an Android project.
Not for Eclipse after I import Gradle. It is setup as a Desktop project.
Then you imported wrong. It is an Android project for me.
Sorry, you are right, I missed some things in my initial commit that I had done on my end for Eclipse.
That worked great - Thanks :)
What must i do to fix the project settings? Bye Phil Am 16.10.2014 15:59 schrieb "Christoph Aschwanden" < notifications@github.com>:
That worked great - Thanks :)
— Reply to this email directly or view it on GitHub https://github.com/libgdx/gdx-pay/issues/2#issuecomment-59365033.
Actually I just run the Android tests and it didn't work. Although it's an Android project now, the dependencies for the jars etc. are not set correctly...
Hmm, works for me.
I don't really have time to help you guys figure out how to export things on your projects I'm afraid.
OK, I fixed the gradle build file. @just4phil: you should be able to run the Android application now. You might want to refresh your gradle setup etc.
Also, I fixed the problem where no payment manager was instantiated the second time around (reflection). Using a static { } initializer meant, the purchase manager was only resolved the first time the app was run but not the second time around.
@noblemaster ... i have no idea what is going wrong here...... i tried all the stuff again....but it still doesnt work.... my OUYApurchaseManager is always == null. it only works when i manually add the manager like this: PurchaseSystem.setManager(new PurchaseManagerAndroidOUYA(androidApplication, 0));
here is what i did:
github.com: fork https://github.com/libgdx/gdx-pay.git local pc: sourcetree: clone fork to local pc eclipse: import gradle project eclipse: build path -> add project references:
Check Order and Export tab in Build Path settings of android project: Are you exporting everything you need? => ok!
Does Google Play work? Try the following:
Does Google Play work (i.e. non-null)?
OK but what is the gradle wrapper? Am 19.10.2014 17:59 schrieb "Christoph Aschwanden" <notifications@github.com
:
Does Google Play work? Try the following:
- do a fresh checkout of gdx-pay
- run the gradle wrapper
- import the gradle files into Eclipse
- run gdx-pay-tests-android as Android Application
Does Google Play work (i.e. non-null)?
— Reply to this email directly or view it on GitHub https://github.com/libgdx/gdx-pay/issues/2#issuecomment-59654284.
double-click gradlew in the root of the repository.
ok android-test runs on my phone and works! but on OUYA still no manager (==null)
Same error message as before? Would you mind posting it again so I can check where it fails (sorry)!
@noblemaster i added the gdx-pay projects to my game and added them to the build-paths but i always get java.lang.NoClassDefFoundError: com.badlogic.gdx.pay.android.ouya.PurchaseManagerAndroidOUYA (and for the androidIAB too) what can be the reason? (does all that reflection code work properly?)