how can I add the aidl file to Android studio (from the in-app billing example)

后端 未结 10 594
我寻月下人不归
我寻月下人不归 2020-11-27 11:45

I am currently migrating an Eclipse app to Android Studio. This app was using the in app billing.

My main problem is to compile the project and the aidl file (I gues

相关标签:
10条回答
  • 2020-11-27 12:01

    The rest of posts here didn't work for me till I created a new folder like shown here.

    0 讨论(0)
  • 2020-11-27 12:08

    Add this code in build.gradle

    android {
        sourceSets {
            main {
                aidl.srcDirs = ['src']
            }
        }
    }
    

    Rebuild and import aidl class

    0 讨论(0)
  • 2020-11-27 12:10

    Just as the error message says, you need to put IInAppBillingService.aidl in the correct directory dictated by it's package (com.android.vending.billing).

    Within the src/main/aidl/ folder you already have, put the .aidl file in com/android/vending/billing/.

    0 讨论(0)
  • 2020-11-27 12:10
    • Create new directory under src/main called aidl
    • Right click on directory aidl, select new->add package
    • Enter Name of the package com.android.vending.billing

    • Copy IInAppBillingService.aidl from the directory Android/Sdk/extras/google/play_billing to the directory App_name/app/src/main/aidl/com/android/vending/billing

    • Now go ahead with InApp billing coding and while defining InApp related services you will get an error can not resolve symbol IInAppBillingXXXXXX
    • Now goto to Build from android studio menu , click on Rebuild Project. This will generate IInAppBillingService.java file inside App_Name/app/build/generated/source/aidl/debug/com/android/vending/billing. This will solve the issue.
    0 讨论(0)
  • 2020-11-27 12:18

    restarting Android Studio worked for me

    a second silly thing that took me a while. I dropped the code on Android Studio to allow him create the file, but he created a .java (as expected) instead a .aidl Jiji, stupid of me

    0 讨论(0)
  • 2020-11-27 12:21

    We need to add

    1. create folder - src/main/aidl/packagename and place aidl file under this.

    2. In the aidl file - mention the package name. package packagename

    Now clean the project, rebuild the project - We can the corresponding java file for the aidl generated in app\build\generated\source\aidl\debug\packagename\youraidl.java

    0 讨论(0)
提交回复
热议问题