libgdx / gdx-pay

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

Class not found: AndroidGooglePlayPurchaseManager #130

Closed aberkowski closed 7 years ago

aberkowski commented 7 years ago

I'm getting an exception

11-02 17:06:10.224: D/GdxPay/IAP(28701): Failed to locate purchase manager for GooglePlay (gdx-pay-android-googleplay.jar file not installed) 11-02 17:06:10.224: D/GdxPay/IAP(28701): java.lang.ClassNotFoundException: com.badlogic.gdx.pay.android.googleplay.AndroidGooglePlayPurchaseManager 11-02 17:06:10.224: D/GdxPay/IAP(28701): at java.lang.Class.classForName(Native Method) 11-02 17:06:10.224: D/GdxPay/IAP(28701): at java.lang.Class.forName(Class.java:309) 11-02 17:06:10.224: D/GdxPay/IAP(28701): at java.lang.Class.forName(Class.java:273) 11-02 17:06:10.224: D/GdxPay/IAP(28701): at com.badlogic.gdx.pay.android.IAP.(IAP.java:125) 11-02 17:06:10.224: D/GdxPay/IAP(28701): at com.badlogic.gdx.pay.android.IAP.setup(IAP.java:93) 11-02 17:06:10.224: D/GdxPay/IAP(28701): at java.lang.reflect.Method.invoke(Native Method) 11-02 17:06:10.224: D/GdxPay/IAP(28701): at java.lang.reflect.Method.invoke(Method.java:372) 11-02 17:06:10.224: D/GdxPay/IAP(28701): at com.badlogic.gdx.utils.reflect.Method.invoke(Method.java:108) 11-02 17:06:10.224: D/GdxPay/IAP(28701): at com.badlogic.gdx.pay.PurchaseSystem.resolve(PurchaseSystem.java:70) 11-02 17:06:10.224: D/GdxPay/IAP(28701): at com.badlogic.gdx.pay.PurchaseSystem.getManager(PurchaseSystem.java:90) 11-02 17:06:10.224: D/GdxPay/IAP(28701): at com.badlogic.gdx.pay.PurchaseSystem.hasManager(PurchaseSystem.java:99)

in method

PurchaseSystem.hasManager()

after updating gdx-pay to '0.10.3' version (from 0.5.0 version). I run game on real Android device connected to PC with USB cable. My build.gradle:

buildscript 
{
    project.ext.robopodsVersion = "2.2.1-SNAPSHOT"
    repositories 
    {
        mavenLocal()
        mavenCentral()
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
    }
    dependencies 
    {
        classpath 'com.android.tools.build:gradle:0.9+'
        classpath 'com.mobidevelop.robovm:robovm-gradle-plugin:2.2.1-SNAPSHOT'      
    }
}

allprojects 
{
    apply plugin: "eclipse"
    apply plugin: "idea"

    version = '1.0'
    ext 
    {
        appName = 'XXXXXXXXXXXXXXX'
        gdxVersion = '1.9.5-SNAPSHOT'        
        roboVMVersion = '2.2.1-SNAPSHOT'
        gdxPay = "0.10.3";
    }

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

project(":core") 
{
    apply plugin: "java"
    dependencies 
    {
        compile "com.badlogicgames.gdx:gdx:$gdxVersion"
        compile "com.badlogicgames.gdxpay:gdx-pay-client:$gdxPay"
        compile "com.badlogicgames.gdx:gdx-controllers:$gdxVersion"        
    }
}

project(":desktop") 
{
    apply plugin: "java"
    dependencies 
    {
        compile project(":core")
        compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
        compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
        compile "com.badlogicgames.gdx:gdx-controllers-desktop:$gdxVersion"
        compile "com.badlogicgames.gdx:gdx-controllers-platform:$gdxVersion:natives-desktop"        
    }
}

project(":android") 
{
    apply plugin: "android"
    configurations { natives }
    dependencies 
    {
        compile project(":core") 
        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-x86"
        compile "com.badlogicgames.gdxpay:gdx-pay-android:$gdxPay"      
        compile "com.badlogicgames.gdxpay:gdx-pay-android-googleplay:${gdxPay}@aar"
    }
}

project(":ios") 
{
    apply plugin: "java"
    apply plugin: "robovm"
    dependencies 
    {
        compile project(":core")
        compile "com.mobidevelop.robovm:robovm-rt:$roboVMVersion"
        compile "com.mobidevelop.robovm:robovm-cocoatouch:$roboVMVersion"
        compile "com.badlogicgames.gdx:gdx-backend-robovm:$gdxVersion"
        compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios"        
        compile "com.badlogicgames.gdxpay:gdx-pay-iosrobovm-apple:$gdxPay"
        compile "com.mobidevelop.robovm:robopods-google-mobile-ads-ios:$robopodsVersion"
    }
}
keesvandieren commented 7 years ago

Have you enabled proguard?

Dependencies seems to be correct, so I think its probably proguard?

The suggested Proguard on wiki start page seems to be not mentioning critical configuration, this page does: https://github.com/libgdx/gdx-pay/wiki/Proguard

If this page resolves your problem, can you please make a pull-request to update gdx-pay README.md? Thanks!

aberkowski commented 7 years ago

It is a debug version where I'm not using proguard. To be sure I added this line to proguard: -keep public class com.badlogic.gdx.pay.android.googleplay.AndroidGooglePlayPurchaseManager { public protected *; } I added even this line: -keep class com.badlogic.** {*;} without succes.

keesvandieren commented 7 years ago

Can you create a minimal sample project? This is such a project used to reproduce another issue:

https://github.com/jsvitek/gdx_pay_issue118

aberkowski commented 7 years ago

I'm using Eclipse - is Eclipse support .aar files? When I change the 'android-googleplay' dependency from '.aar' to '.jar' everything works fine...

keesvandieren commented 7 years ago

I have never done any Android development in the pre-Gradle toolchain. So I don't know if aar is supposed to work.

Can you find out if there is some official documentation about aar support of Eclipse? If you find someone, we can extend README.md that eclipse users must use the jar

aberkowski commented 7 years ago

I cannot find any official documentation but there are some posts on the net about this problem, for example: https://commonsware.com/blog/2014/07/03/consuming-aars-eclipse.html . Some people writes that you have to extract .aar file and there is a 'classes.jar' file which can be used in the eclipse project. I extracted 'gdx-pay-android-googleplay.aar' file and there was 'classes.jar' file but it was smaller and different than original 'gdx-pay-android-googleplay.jar' file so I don't know it is true...

keesvandieren commented 7 years ago

I think the 'gdx-pay-android-googleplay.jar' is an uberjar, containing all gdx-pay dependencies of android-googleplay.

centy commented 7 years ago

@Berobasket Theoretically it is possible to "convert" aar for eclipse, however I propose to switch to Android Studio. It is much simpler :)

aberkowski commented 7 years ago

I don't want to switch to Android studio because now I'm able to manage projects for Android, iOS and desktop from one place. This is crucial for me

keesvandieren commented 7 years ago

You mean libgdx desktop / iOS projects? We do so as wel, with Android Studio. As long as you use Gradle, you're fine.

aberkowski commented 7 years ago

I didn't know about it... So I think that it's time for a change ;)

centy commented 7 years ago

@Berobasket AndroidStudio works good, to configure and debug desktop you have to setup it like this:

image

aberkowski commented 7 years ago

Ok, thanks a lot

aberkowski commented 7 years ago

I've changed IDE to Android Studio and now everything works fine. I have no more problems with AndroidGooglePlayPurchaseManager class. @keesvandieren and @centy thanks for help - Android Studio works great with Android, iOS and desktop projects :)