简体   繁体   English

gdx-pay: "包 com.badlogic.gdx.pay 不存在"

[英]gdx-pay: "package com.badlogic.gdx.pay does not exist"

I'm trying to implement gdx-pay in my libgdx project.我正在尝试在我的 libgdx 项目中实现 gdx-pay。 So I followed the Integration example with resolvers from the libgdx wiki.所以我遵循了来自 libgdx wiki 的带有解析器集成示例

I have created a class PlatformResolver in my core project and a class AndroidResolver in my android project (as in the wiki).我在我的核心项目中创建了一个PlatformResolver类,在我的 android 项目中创建了一个AndroidResolver类(如在 wiki 中)。 Both classes import com.badlogic.gdx.pay.PurchaseManagerConfig , but for my AndroidResolver I get a compiler error:这两个类都导入com.badlogic.gdx.pay.PurchaseManagerConfig ,但对于我的AndroidResolver我得到一个编译器错误:

Error:(6, 28) error: package com.badlogic.gdx.pay does not exist

I have imported the gdx-pay-0.4.0-library.jar (which includes com.badlogic.gdx.pay.PurchaseManagerConfig ) to my core project and 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 to my android project.我已将gdx-pay-0.4.0-library.jar (包括com.badlogic.gdx.pay.PurchaseManagerConfigcom.badlogic.gdx.pay.PurchaseManagerConfig到我的核心项目和gdx-pay-android-openiab-0.4.0-library.jargdx-pay-android-0.4.0-library.jar , gdx-pay-android-ouya-0.4.0-library.jar到我的 android 项目。

As the android project also compiles the core project, PurchaseManagerConfig should be available to the android project, too, shouldn't it?由于 android 项目也编译核心项目, PurchaseManagerConfig应该也可用于 android 项目,不是吗?

project(":android") {
    apply plugin: "android"

    configurations { natives }

    dependencies {
        compile project(":core")
        // ...
        compile fileTree(dir: 'libs', include: '*.jar')
    }
}

Any ideas what's going wrong?任何想法出了什么问题?

EDIT:编辑:

When I add gdx-pay-0.4.0-library.jar additionally to the android project (folder android/lib), everything compiles fine (still no idea why it's neccessary).当我将gdx-pay-0.4.0-library.jar添加到 android 项目(文件夹 android/lib)中时,一切都可以正常编译(仍然不知道为什么它是必需的)。 But then I could never restore or buy items because of但后来我永远无法恢复或购买物品,因为

I/ERROR﹕ gdx-pay: requestPurchaseRestore(): purchaseManager == null

But this seems to be a ProGuard problem.但这似乎是一个 ProGuard 问题。 Without ProGuard I get:没有 ProGuard 我得到:

I/IAP﹕ IAP: gdx-pay successfully instantiated.
I/﹕ gdx-pay: installed manager: OpenIAB/null

Although my project compiles now, I nevertheless would be glad if somebody could explain me why I have to add the jar file twice because that could help me understand some other gradle issues.尽管我的项目现在可以编译,但如果有人能解释我为什么必须两次添加 jar 文件,我会很高兴,因为这可以帮助我理解其他一些 gradle 问题。

Try this:尝试这个:

In build.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"
}

} }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM