LibGDX应用内购买和Gradle

Oli*_*xon 5 java android gradle libgdx

我正在尝试在我的项目中实施应用内购买,该项目在Android Studio中使用gradle.

我的问题是,我不知道如何在项目中包含Android-sdk.

例如,如果我尝试创建像IabHelper对象这样简单的东西,它甚至无法解析(这让我觉得库不起作用).

有没有人有这方面的经验?我一直试图在我休息的个人时间整天解决这个问题,非常令人沮丧.

我目前的gradle文件:

buildscript {
    repositories {
        mavenCentral()
        mavenLocal()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.13.2'
        classpath 'com.github.jtakakura:gradle-robovm-plugin:0.0.9'
    }
}

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

    version = '1.0'
    ext {
        appName = 'MyAppName'
        gdxVersion = '1.4.1'
        //roboVMVersion = '0.0.13'
        roboVMVersion = '1.0-beta-01'
    }

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

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-box2d-platform:$gdxVersion:natives-desktop"
        compile "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-desktop"
        compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"
        compile "com.badlogicgames.gdx:gdx-tools:$gdxVersion"
        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.gdx:gdx-bullet:$gdxVersion"
        natives "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-armeabi"
        natives "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-armeabi-v7a"
        natives "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-x86"
        compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
        natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi"
        natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi-v7a"
        natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86"
        compile "com.badlogicgames.box2dlights:box2dlights:1.2"
        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-x86"
        compile "com.badlogicgames.gdx:gdx-controllers:$gdxVersion"
        compile "com.badlogicgames.gdx:gdx-controllers-android:$gdxVersion"
    }
}

project(":ios") {
    apply plugin: "java"
    apply plugin: "robovm"

    configurations { natives }

    dependencies {
        compile project(":core")
        compile "org.robovm:robovm-rt:${roboVMVersion}"
        compile "org.robovm:robovm-cocoatouch:${roboVMVersion}"
        compile "com.badlogicgames.gdx:gdx-backend-robovm:$gdxVersion"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios"
        natives "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-ios"
        natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-ios"
        compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
        natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-ios"
    }
}

project(":core") {
    apply plugin: "java"

    dependencies {
        compile "com.badlogicgames.gdx:gdx:$gdxVersion"
        compile "com.badlogicgames.gdx:gdx-bullet:$gdxVersion"
        compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
        compile "com.badlogicgames.gdx:gdx-bullet:$gdxVersion"
        compile "com.badlogicgames.box2dlights:box2dlights:1.2"
        compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
        compile "com.badlogicgames.gdx:gdx-controllers:$gdxVersion"

        //compile "com.badlogicgames.gdx:gdx-ai:1.4.0"

        compile 'net.dermetfan.libgdx-utils:libgdx-utils:0.4.0'
        compile 'net.dermetfan.libgdx-utils:libgdx-utils-box2d:0.4.0' // Box2D module
    }
}

tasks.eclipse.doLast {
    delete ".project"
}
Run Code Online (Sandbox Code Playgroud)

**更新**

不幸的是,经过整整一周的努力,我无法解决这个问题,我甚至重新格式化了我的MAC并重新加载了所有内容,但没有用.摇篮...

无论如何,我通过使用一个只需要一行代码的优秀第三方库来解决:

https://github.com/anjlab/android-inapp-billing-v3

Kat*_* A. 0

我希望你至少需要这个project(":android")

android {
buildToolsVersion "19.0.3"
compileSdkVersion 19
}
Run Code Online (Sandbox Code Playgroud)