- Home /
Difficulty with Android IMarketBillingService
Hello,
I've been trying to get in app purchasing on Android up and running and I'm running into a wall with the IMarketBillingService.aidl file supplied by Google. I can't get this file to auto generate a .java using Ant. (note: this part is solved, see Update & Update 2).
I tried using the .java file from the sample project supplied but I'm having difficulty importing it into my project to use. I got it working by changing the package name but that won't work as it must have the package name com.android.vending.billing otherwise you get a security exception when trying to use it.
Can anyone who has implemented Android in app purchasing with Unity offer some advice?
Thanks.
UPDATE:
The problem is almost certainly in the build.xml. I've implemented the Openfeint plugin so my build.xml is the same as the one that came with that. I can see how the original bild.xml in the sdk mentions .aidl files so I just need to modify my own to work.
I've added:
<property name="android.platform.tools.dir" location="${sdk.dir}/platform-tools" />
<property name="aidl" location="${android.platform.tools.dir}/aidl.exe" />
<target name="-code-gen">
<echo>----------</echo>
<echo>Handling aidl files...</echo>
<aidl executable="${aidl}" framework="${android.aidl}"
genFolder="${gen.absolute.dir}">
<source path="${source.absolute.dir}"/>
</aidl>
</target>
But I'm not getting the error aidl: Cant' open preprocessed file: [...]Assets/Plugins/Android/${android.aidl}
Update 2:
(side note: why can't I edit comments? I have to delete then add a new one?)
So I've managed to get the file auto-generating by manually pointing to the correct framework:
<property name="android.aidl" location="${sdk.dir}/platforms/android-8/framework.aidl" />
Note nice but working, however I still can't import it as I get the error package com.android.vending.billing does not exist, even though the generated .java file has that package name and is located in /Assets/Plugins/Android/gen/com/android/vending/billing.
Any ideas?
Answer by HazeTI · Mar 08, 2012 at 12:16 AM
So I got in a state where everything compiles and I can now progress, although I'm not very happy with the solution.
I couldn't import any .java files from /Assets/Plugins/Android/gen/. (for some reason, I'm not sure why as I can perfectly fine in other non-unity projects) so I've had to change the build.xml to place the generated .java file in my source folder instead.
Answer by maxgreen · Sep 22, 2012 at 04:31 PM
You should take a look at an open source project - http://project.soom.la. It's an in-app billing library for Android. You can either use the code as reference or you can just take the whole thing and use as a billing SDK. It makes Android billing, simple and more secure and it also has a sample app for reference.