可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
I was doing this following these steps as mentioned in the link.
- Copy the
IInAppBillingService.aidl
file to your Android project.
(1) If you are using Eclipse: Import the IInAppBillingService.aidl
file into your /src directory.
(2) If you are developing in a non-Eclipse environment: Create the following directory /src/com/android/vending/billing and copy the IInAppBillingService.aidl
file into this directory.
- Build your application. You should see a generated file named
IInAppBillingService.java
in the /gen
directory of your project.
- Add the helper classes from the
/util
directory of the TrivialDrive
sample to your project. Remember to change the package name declarations in those files accordingly so that your project compiles correctly.
But when I finished that, Eclipse gives me an error:
interface IInAppBillingService should be declared in a file called com\android\vending\billing\IInAppBillingService.aidl.
the aidl
file is in the correct directory, but the IInAppBillingService.java
file was not generated.
Has anybody seen that before?
回答1:
right click on the head of the project and create a new PACKAGE ... call the package com.android.vending.billing ....drop the aidl file in there to quiet the error.
Some food for thought: for those with an interest - when using someone's aidl file, the package name for both apps must be the same. google used com.android.vending.billing as their package name for their billing aidl interface, so you MUST also use the same package name in your app. This is the rule when using aidl.
回答2:
For android studio users, this should be the structure:
Worked for me, according to this answer.
回答3:
The structure that @David mentioned works fine in Android Studio 1.2.
Your path for the billing folder should look like:
[YOUR_APP_FOLDER]/app/src/main/aidl/com/android/vending/billing/IInAppBillingService.aidl
This is where you can check the IInAppBillingService.java generated file:
[YOUR_APP_FOLDER]/app/build/generated/source/aidl/debug/com/android/vending/IInAppBillingService.java
Good luck !
回答4:
In the /src directory, click File > New > Package, then create a package named com.android.vending.billing
Copy the IInAppBillingService.aidl file from /extras/google/play_billing/ and paste it into the src/com.android.vending.billing/ folder in your workspace.
Build your application. You should see a generated file named IInAppBillingService.java in the /gen directory of your project.
回答5:
The only advice I can give you is to re-check spelling of the directories in your src folder, if you put the file into /src/com/android/vending/billing/IInAppBillingService.aidl it should work
回答6:
The other suggestions are good. Sometimes eclipse may just be weird though, and a project clean can fix it in this case.
回答7:
I did what @j2emanue suggested (click New/Package, add "com.android.vendor.billing"), and I also added that directories to my file system (com/android/vendor/billing) then copied the file in it. Then, clicked Refresh on the project. Build, and it succeeded.
回答8:
Check that you have added billing library in your build.gladle under dependencies
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.billingclient:billing:1.1'
}
See the last line in the above code. Implementing 'com.android.billingclient:billing:1.1' solved same problem for me
回答9:
2018
app/build.gradle:
sourceSets {
main {
aidl.srcDirs = ['src/main/aidl']
}
}
or
sourceSets {
main {
aidl.srcDirs = ['src']
}
}
for IInAppBillingService.aidl