我正在尝试在我的 libgdx 项目中实现 gdx-pay。所以我按照Integration example with resolvers来自 libgdx wiki。
我在我的核心项目中创建了一个类 PlatformResolver
,并在我的 android 项目中创建了一个类 AndroidResolver
(如 wiki 中所示)。这两个类都导入 com.badlogic.gdx.pay.PurchaseManagerConfig
,但对于我的 AndroidResolver
,我收到编译器错误:
Error:(6, 28) error: package com.badlogic.gdx.pay does not exist
我已将 gdx-pay-0.4.0-library.jar
(其中包括 com.badlogic.gdx.pay.PurchaseManagerConfig
)导入到我的核心项目中,并且gdx-pay-android-openiab-0.4.0-library.jar
、gdx-pay-android-0.4.0-library.jar
、gdx-pay -android-ouya-0.4.0-library.jar
到我的 android 项目。
由于 android 项目也会编译核心项目,因此 PurchaseManagerConfig
也应该可供 android 项目使用,不是吗?
project(":android") {
apply plugin: "android"
configurations { natives }
dependencies {
compile project(":core")
// ...
compile fileTree(dir: 'libs', include: '*.jar')
}
}
知道出了什么问题吗?
编辑:
当我将gdx-pay-0.4.0-library.jar
添加到android项目(文件夹android/lib)中时,一切都可以正常编译(仍然不知道为什么它是必要的)。但后来我永远无法恢复或购买元素,因为
I/ERROR﹕ gdx-pay: requestPurchaseRestore(): purchaseManager == null
但这似乎是一个 ProGuard 问题。没有 ProGuard 我得到:
I/IAP﹕ IAP: gdx-pay successfully instantiated.
I/﹕ gdx-pay: installed manager: OpenIAB/null
虽然我的项目现在可以编译,但如果有人能解释为什么我必须添加 jar 文件两次,我会很高兴,因为这可以帮助我理解其他一些 gradle 问题。
最佳答案
试试这个:
在 build.gradle 中:
project(":android") {
apply plugin: "android"
configurations { natives }
dependencies {
***
compile "com.badlogicgames.gdxpay:gdx-pay-android:0.9.2"
compile "com.badlogicgames.gdxpay:gdx-pay-android-openiab:0.9.2:library"
compile "com.badlogicgames.gdxpay:gdx-pay-android-ouya:0.9.2:library"
}
}
关于java - gdx-支付 : "package com.badlogic.gdx.pay does not exist",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30851556/