Shopping with LibGDX and Gradle

I am trying to implement in-app purchases for my project that uses gradle in Android Studio.

My problem is that I do not know how to include Android-sdk in the project.

For example, if I try to create something simple, for example, an IabHelper object, it cannot even be resolved (which makes me think that the library is not working).

Does anyone have any experience with this? I try to resolve this all day in my personal time on my day off, very frustrating.

My current gradle file:

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" } 

** UPDATE **

Unfortunately, I could not solve this problem after a whole week of efforts, I even reformatted my MAC and completely rebooted everything, it did not work. Gradle ...

Anyway, I decided using an excellent third-party library, which requires only one line of code:

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

+5
source share
2 answers

I would expect you to need at least this in your project(":android")

 android { buildToolsVersion "19.0.3" compileSdkVersion 19 } 
0
source

IabHelper located in package com.example.android.trivialdrivesample.util . According to the official documentation , you should copy the utils directory with the IabHelper class from the IabHelper sample application into your project.

To add a version 3 billing library to an existing billing project in an application:

  • Copy the IInAppBillingService.aidl file into your Android project.

    • In Android Studio: create a directory under aidl under src/main , add a new package> com.android.vending.billing to this directory and import the IInAppBillingService.aidl file into this package.

    • In Eclipse: import the IInAppBillingService.aidl file into the / src directory.

    • In other development environments: create the following directory /src/com/android/vending/billing and copy the IInAppBillingService.aidl file into this directory.

  • Create an application. You should see a generated file named IInAppBillingService.java in the / gen directory of your project.

  • Add helper classes from the /util directory of the TrivialDrive sample to your project. Remember to change the package name declarations in these files accordingly so that your project compiles correctly.

Your project should now contain the In-app Billing Version 3 library.

After these steps, you can create the IabHelper object in your code.

0
source

Source: https://habr.com/ru/post/1208631/


All Articles