How to implement native Google Play In-app billing in a libGDX project?

115 views Asked by At

I was following this and stuck at "a. Navigate to src/main in the Project tool window."

Because I couldn't find src/main in my project structure (Neither in the explorer)

enter image description here

Like it is shown here:

enter image description here

I think it's because I'm working with a libGDX project.


I tried adding the Module directly under the src (As if I was not working in a android studio environment), but when I build my application, I don't see a generated file named IInAppBillingService.java anywhere.

enter image description here

1

There are 1 answers

9
Code-Apprentice On BEST ANSWER

If you open build.gradle in the android folder of your project, you will see the following block of Gradle code:

sourceSets {
    main {
        manifest.srcFile 'AndroidManifest.xml'
        java.srcDirs = ['src']
        aidl.srcDirs = ['src']
        renderscript.srcDirs = ['src']
        res.srcDirs = ['res']
        assets.srcDirs = ['assets']
        jniLibs.srcDirs = ['libs']
    }

    instrumentTest.setRoot('tests')
}

This block configures where Gradle looks for source files. LibGDX uses this to customize the directory hierarchy which is why you are unable to exactly follow the steps given in the Android documentation.

Now the line aidl.srcDirs = ['src'] tells us that the project is configured so that all AIDL files can be placed directly in the src folder. So you can modify the step to navigate to src/main and instead just go directly to src. Follow the rest of the instructions from there. If Android Studio balks at any step, you may have to go directly to the file system using the command line or your favorite file explorer in order to create the folders and files that you need.

It appears you have done this and the second part (or maybe the primary part?) of your question is the location of the generated .java file from your AIDL source. Android Studio places all generated artifacts under the build directory. There is a build folder directly in the base directory of your project and one in each module. Search these for the generated file.