libgdx / gdx-pay

A libGDX cross-platform API for InApp purchasing.
Apache License 2.0
225 stars 83 forks source link

cant work with libraries #9

Closed just4phil closed 9 years ago

just4phil commented 9 years ago

@noblemaster hi chris! i just wanted to try to work with the gradle dependencies. i added to gradle.build:

gdxpayVersion = '0.2.0-SNAPSHOT' compile "com.badlogicgames.gdxpay:gdx-pay:$gdxpayVersion:library"

after gradle-refresh all the compiling worked without errors, but i cant import the classes in eclipse. PurchaseSystem.hasManager() => PurchaseSystem cannot be resolved

what can be the reason?

just4phil commented 9 years ago

it works when i change it to the normal jar: compile "com.badlogicgames.gdxpay:gdx-pay:$gdxpayVersion"

so maybe the fat library doesnt work? (imho would be good to have it!)

noblemaster commented 9 years ago

Got it! Looks like I was adding source java files instead of the compiled class files (Gradle build file wrong). In any case, I fixed it and uploaded a new snapshot release. Please try again and let me know if it works now.

just4phil commented 9 years ago

@noblemaster is it still 0.2.0-SNAPSHOT ? when i delete ouya.jar and openIAB.jar and use library-versions of 0.2.0-SNAPSHOT instead then it doesnt work. the purchase doesnt start because the purchaseManager == null (that is always the case when ouya.jar / openIAB.jar are not compiled in...) or i get PurchaseSystem.hasManager() => PurchaseSystem cannot be resolved (depends on what i am doing....)

just4phil commented 9 years ago

maybe i am doing something wrong..... here is my setup: i have a framework/engine project. its only a core project... it has a platformresolver that uses: if (PurchaseSystem.hasManager()) PurchaseSystem.install(purchaseObserver, config); if (PurchaseSystem.hasManager()) PurchaseSystem.dispose(); this framework project compiles only the the main gdx pay project: compile "com.badlogicgames.gdxpay:gdx-pay:$gdxpayVersion"

if i use the library-version there, then i get PurchaseSystem.hasManager() => PurchaseSystem cannot be resolved.... if i use the normal version its ok.

my game projects uses this framework project (added to buildpath)

must i use the library versions evrywhere? i thought it should be ok to use them only in android project?: compile "com.badlogicgames.gdxpay:gdx-pay-android-openiab:$gdxpayVersion:library" compile "com.badlogicgames.gdxpay:gdx-pay-android-ouya:$gdxpayVersion:library"

however...it doesnt work..... :(


another thing i just found out: when i add this to build.gradle: compile "com.badlogicgames.gdxpay:gdx-pay:$gdxpayVersion:library" compile "com.badlogicgames.gdxpay:gdx-pay-android:$gdxpayVersion:library" compile "com.badlogicgames.gdxpay:gdx-pay-android-openiab:$gdxpayVersion:library" compile "com.badlogicgames.gdxpay:gdx-pay-android-ouya:$gdxpayVersion:library"

then after the gradle refresh i have : gdx-pay + gdx-pay.library gdx-pay.android + gdx-pay.android.library in the build path

why are those dependencies doubled?

just4phil commented 9 years ago

as a comparison (my regular environment with sources that works best):

project - in buildPath

noblemaster commented 9 years ago

That project setup looks OK.

then after the gradle refresh i have :
gdx-pay + gdx-pay.library
gdx-pay.android + gdx-pay.android.library in the build path

I guess there is only one POM and it references the gdx-pay rather than the gdx-pay.library. In the end, it shouldn't really matter. In order to remove the duplicates, try the following (the dependencies will/should add the rest):

    the core project:
    compile "com.badlogicgames.gdxpay:gdx-pay:$gdxpayVersion"

    the android project:
    compile "com.badlogicgames.gdxpay:gdx-pay-android-openiab:$gdxpayVersion:library"
    compile "com.badlogicgames.gdxpay:gdx-pay-android-ouya:$gdxpayVersion:library"

The ouya-sdk.jar & openiab-0.9.7.2.jar are insides those library jars. To make sure they are correct, compare e.g. to https://oss.sonatype.org/content/repositories/snapshots/com/badlogicgames/gdxpay/gdx-pay-android-openiab/0.2.0-SNAPSHOT/gdx-pay-android-openiab-0.2.0-20141103.051253-8-library.jar It's the snapshot you should have downloaded/installed on your machine. The com.android/com.amazon.* should be included as packages within your local jar (just unzip & have a look).

What you can try to is to download the latest snapshot releases and add them to your project manually: https://oss.sonatype.org/content/repositories/snapshots/com/badlogicgames/gdxpay/ Make sure you take the latest *-library.jar from each of the 0.2.0-SNAPSHOT. If you do it manually you would end up with the following jars:

    engine-core
        gdx-pay-library.jar (export it in Eclipse so it's available within game-core)

    game-core
        engine-core

    game-android
        engine-core
        game-core
        gdx-pay-android-library.jar
        gdx-pay-android-openiab-library.jar
        gdx-pay-android-ouya-library.jar
        gdx-pay-library.jar

Does adding all those manually work?

just4phil commented 9 years ago

@noblemaster

ok... the duplicates are gone now. its sufficient to compile gdx-pay-android-openiab and gdx-pay-android-ouya.

but the library-versions still dont work in my game.... purchasemanager == null

next i will try to add them manually

just4phil commented 9 years ago

@noblemaster when i remove gdx-pay-android-openiab and gdx-pay-android-ouya and then manually add the downloaded jars: gdx-pay-android-ouya-0.2.0-20141103.051303-8-library.jar gdx-pay-android-openiab-0.2.0-20141103.051253-8-library.jar

then it works!

after that i changed back to the gradle dependencies.... and removed the jars again. then i got a strange message that never appeared before: "output folder has changed.... do you want to remove all generated ressources from ...android/bin/classes?"

i said YES.... and now it works with the fat-libraries via gradle, too!

very mysterious.... gradle is cool! but it seems to be very error prone for unexperienced users....

noblemaster commented 9 years ago

I'm glad it's working! :)

I guess Gradle works in mysterious ways. Probably some caching issue, who knows. From what I have seen, Gradle's Eclipse integration is severely lacking. Not to keen on Gradle's file format either where most of the stuff is preset and hidden. Unless you do it the Gradle-way you will run into problems. In any case I'll wait until Gradle improves or even better hopefully something better comes along...