libgdx / gdx-pay

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

No purchase manager found IN LIVE WALLPAPER #139

Closed klaszlo8207 closed 7 years ago

klaszlo8207 commented 7 years ago

I used this code

https://github.com/libgdx/gdx-pay/blob/master/gdx-pay-tests/src/com/badlogic/gdx/pay/tests/PayTest.java

It is always say that:

"- no purchase manager found"

What does it mean?

itsabhiaryan commented 7 years ago

On which platform you're running PayTest Application.

It simply say that your PurchaseSystem having no PurchaseManager. Your Gdx.app.getType() should be Application.ApplicationType.iOS or Application.ApplicationType.Android.

klaszlo8207 commented 7 years ago

Hello,

here is my dependencies:


dependencies {
    compile files('libs/gdx.jar')
    compile files('libs/gdx-backend-android.jar')
    compile files('libs/gdx-freetype.jar')
    compile files('libs/gdx-bullet.jar')
    compile 'com.github.yukuku:ambilwarna:2.0.1'

    compile files('libs/gdx-pay-android-0.10.3-library.jar')
    compile files('libs/gdx-pay-android-googleplay-0.10.3.jar')
    compile files('libs/gdx-pay-0.10.3-library.jar')
    compile files('libs/gdx-pay-client-0.10.3-library.jar')
}

It is for android. I just copy pasted the dependencies and then the example project's code on my android live wallpaper.

I just uploaded my SIGNED APK to the Google Play console in beta version and wait for approval. And I added some pay service on the gogole play dev console for this app.

Maybe we have to wait until the apk downloadable for beta version and then the purchase manager will be available? Thanks

Oh and I using ProGuard

my proguard file is

-verbose

-dontwarn android.support.**
-dontwarn com.badlogic.gdx.backends.android.AndroidFragmentApplication
-dontwarn com.badlogic.gdx.utils.GdxBuild
-dontwarn com.badlogic.gdx.physics.box2d.utils.Box2DBuild
-dontwarn com.badlogic.gdx.jnigen.BuildTarget*
-dontwarn com.badlogic.gdx.physics.bullet.BulletBuild*
-dontwarn com.badlogic.gdx.graphics.g2d.freetype.FreetypeBuild*
-dontwarn android.test.**
-dontwarn com.badlogic.gdx.pay**

-keepclassmembers class com.badlogic.gdx.backends.android.AndroidInput* {
   <init>(com.badlogic.gdx.Application, android.content.Context, java.lang.Object, com.badlogic.gdx.backends.android.AndroidApplicationConfiguration);
}

-keepclassmembers class com.badlogic.gdx.physics.box2d.World {
   boolean contactFilter(long, long);
   void    beginContact(long);
   void    endContact(long);
   void    preSolve(long, long);
   void    postSolve(long, long);
   boolean reportFixture(long);
   float   reportRayFixture(long, float, float, float, float, float);
}

-keep class com.android.vending.billing.**

UPDATE: I downloaded in BETA version, and it is saying again: No purchase manager found!.

if (PurchaseSystem.hasManager()) {

this i always FALSE. Why? Thanks

klaszlo8207 commented 7 years ago

I updated to gradle build:

In Live wallpaper create() I got only:

No purchase manager found!.

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        mavenLocal()
        mavenCentral()
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.3'
    }
}

allprojects {

    ext {
        appName = "my-gdx-game"
        gdxVersion = '1.9.5'
        roboVMVersion = '2.3.0'
        box2DLightsVersion = '1.4'
        ashleyVersion = '1.7.0'
        aiVersion = '1.8.0'
        gdxPayVersion = '0.10.3'
    }

    repositories {
        mavenLocal()
        mavenCentral()
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
        maven { url "https://oss.sonatype.org/content/repositories/releases/" }
    }

}

//app

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
            jniLibs.srcDirs = ['libs']
        }
    }
configurations { natives }

dependencies {
    /*
    compile files('libs/gdx.jar')
    compile files('libs/gdx-backend-android.jar')
    compile files('libs/gdx-freetype.jar')
    */
    compile "com.badlogicgames.gdx:gdx:$gdxVersion"

    compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
    natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
    natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
    natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a"
    natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
    natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"
    compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
    natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi"
    natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi-v7a"
    natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-arm64-v8a"
    natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86"
    natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86_64"

    compile "com.badlogicgames.gdxpay:gdx-pay-client:$gdxPayVersion"
    compile "com.badlogicgames.gdxpay:gdx-pay-android:$gdxPayVersion"
    compile "com.badlogicgames.gdxpay:gdx-pay-android-googleplay:${gdxPayVersion}@aar"

    /*
    compile files('libs/gdx-pay-android-0.10.3-library.jar')
    compile files('libs/gdx-pay-android-googleplay-0.10.3.jar')
    compile files('libs/gdx-pay-0.10.3-library.jar')
    compile files('libs/gdx-pay-client-0.10.3-library.jar')
    */
    compile 'com.github.yukuku:ambilwarna:2.0.1'
}

// called every time gradle gets executed, takes the native dependencies of
// the natives configuration, and extracts them to the proper libs/ folders
// so they get packed with the APK.
task copyAndroidNatives() {
    file("libs/armeabi/").mkdirs();
    file("libs/armeabi-v7a/").mkdirs();
    file("libs/arm64-v8a/").mkdirs();
    file("libs/x86_64/").mkdirs();
    file("libs/x86/").mkdirs();

    configurations.natives.files.each { jar ->
        def outputDir = null
        if(jar.name.endsWith("natives-arm64-v8a.jar")) outputDir = file("libs/arm64-v8a")
        if(jar.name.endsWith("natives-armeabi-v7a.jar")) outputDir = file("libs/armeabi-v7a")
        if(jar.name.endsWith("natives-armeabi.jar")) outputDir = file("libs/armeabi")
        if(jar.name.endsWith("natives-x86_64.jar")) outputDir = file("libs/x86_64")
        if(jar.name.endsWith("natives-x86.jar")) outputDir = file("libs/x86")
        if(outputDir != null) {
            copy {
                from zipTree(jar)
                into outputDir
                include "*.so"
            }
        }
    }
}

task run(type: Exec) {
    def path
    def localProperties = project.file("../local.properties")
    if (localProperties.exists()) {
        Properties properties = new Properties()
        localProperties.withInputStream { instr ->
            properties.load(instr)
        }
        def sdkDir = properties.getProperty('sdk.dir')
        if (sdkDir) {
            path = sdkDir
        } else {
            path = "$System.env.ANDROID_HOME"
        }
    } else {
        path = "$System.env.ANDROID_HOME"
    }

    def adb = path + "/platform-tools/adb"
    commandLine "$adb", 'shell', 'am', 'start', '-n', 'com.mygdx.game/com.mygdx.game.AndroidLauncher'
}

THE SAME ERROR!

When I using in a simple app and not in a live wallpaper:

AndroidPlay: Failed to load skus in onServiceConnected() com.badlogic.gdx.pay.android.googleplay.GdxPayException: getProductsDetails([full_version_purchase] failed) after 0 seconds

Caused by: java.lang.IllegalArgumentException: No skus found in response

klaszlo8207 commented 7 years ago

Some News:

IAP: Error creating IAP for Android. java.lang.RuntimeException: Can't find your gdx activity to instantiate Android IAP. Looks like you have implemented AndroidApplication without using Activity or Fragment classes or Activity is not available at the moment

Is it working for Live Wallpapers or not?

klaszlo8207 commented 7 years ago

Thanks but please read my previous comment. Is it working in LWP or not? I think it is only for Activities.

klaszlo8207 commented 7 years ago

the probleme is here:

https://github.com/libgdx/gdx-pay/blob/master/gdx-pay-android/src/com/badlogic/gdx/pay/android/IAP.java

line 87

if (activity == null) { throw new RuntimeException("Can't find your gdx activity to instantiate Android IAP. "

I think this is a BUG. I tried to add in a Live Wallpaper Settings Activity (PreferenceActivity) but the same error :(

IAP: Error creating IAP for Android. java.lang.RuntimeException: Can't find your gdx activity to instantiate Android IAP. Looks like you have implemented AndroidApplication without using Activity or Fragment classes or Activity is not available at the moment

klaszlo8207 commented 7 years ago

The FIX is:

else if (Gdx.app instanceof com.badlogic.gdx.backends.android.AndroidLiveWallpaper) { activity = ...; }

Can somebodey fix this for live wallpapers?

klaszlo8207 commented 7 years ago

OK I returned to the 'com.anjlab.android.iab.v3:library:1.0.+'

Anyway please someone fix the library later, Thanks

keesvandieren commented 7 years ago

Hi,

Have never created a wallpaper app in Android.

Does a Wallpaper app have an Activity?

Does you app have to support for platforms other than Google Play?

klaszlo8207 commented 7 years ago

No, dont have an activity, the solution is the code I just posted yesterday. And I only use this for Google Play. I have only Settings Activity. (PreferenceActivity) Please do an update if you can. Anyway I have no time for this, I using this library: 'com.anjlab.android.iab.v3:library:1.0.+'

And work like a charm

I just posted this BUG in your library

keesvandieren commented 7 years ago

It is much more work than you suggest.

We contributed two weeks of our time to rewrite the Android implementation (e.g. we added gdx-pay-android-googleplay).

Adding support for live-wall-paper takes 2 or 3 days.

We accept and review pull requests (for free). If someone wants to hire us to add support for live wall-paper apps, feel free to contact us via info@squins.com

keesvandieren commented 7 years ago

There are no plans to built in support for wallpapers.

If anyone wants to contribute it we are waiting for PR.