Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
In App Purchases in Android Studio — Gideros Forum

In App Purchases in Android Studio

antixantix Member
edited July 2016 in Bugs and issues
So does anyone have this working and are they willing to part with some help on how to get this working? I'm looking in c:\gideros\allplugins\iab. The instructions aren;t very clear to me. I've made some modifications to my project in Android Studio but when I go to build I see the following error..
C:\Projects\Android Studio\Falling Animals\app\src\main\java\com\giderosmobile\android\plugins\iab\frameworks\google\IabHelper.java
Error:(32, 35) error: package com.android.vending.billing does not exist
Error:(98, 5) error: cannot find symbol class IInAppBillingService
Error:(221, 48) error: package IInAppBillingService does not exist
Note: Some input files use or override a deprecated API.
I can see in src/main/

Comments

  • ar2rsawseenar2rsawseen Maintainer
    Accepted Answer
    Usually with such plugins there are 2 parts

    1) Gideros part, which consists of
    Copying .java files to the right place
    Copying .so files to the right place
    In main activity loading .so file
    In main activity providing external class

    2) Library part, and you can probably find much better instructions on library provider website, in this case, if you are interested in Google IAB, then you can look for instructions on Google IAB for Android Studio

    like this maybe: http://www.techotopia.com/index.php/An_Android_Studio_Google_Play_In-app_Billing_Tutorial
  • antixantix Member
    @ar2sawseen thanks I'll have a read of that and see what happens :)
  • antixantix Member
    edited July 2016
    Following the instructions in the link provided enabled me to get the .aidl file setup in Android Studio and the plugin is working in my game, thanks @ar2sawseen :)

    I am trying to add a consumable item in my game and I can purchase the item fine but how do I inform google that I have consumed the item? on this page there is the following section..
    Managing consumable purchases in your application
     
    Here is the basic flow for purchasing a consumable in-app product:
     
    1. Launch a purchase flow with a getBuyIntent call
    2. Get a response Bundlefrom Google Play indicating if the purchase completed successfully.
    3. If the purchase was successful, consume the purchase by making a consumePurchase call.
    4. Get a response code from Google Play indicating if the consumption completed successfully.
    5. If the consumption was successful, provision the product in your application.
    In C:\Gideros\All Plugins\iab\install.html there doesn't seem to be a function to call consumePurchase () so when I go to purchase more of my items I get an error telling me that the item has already been purchased (presumably because I haven't called consumePurchase() on it).

    None of the examples in C:\Gideros\All Plugins\iab\examples\GiderosProject show how to accomplish this either.

    Help [-O<
  • simwhisimwhi Member
    edited July 2016 Accepted Answer
    @antix Consumable items are your responsibility. You decide which items are consumable in your code and when / how they are consumed.

    As an example, I set up our consumable items like this:
    self.IAB:setProducts({coinsLow = self.coinsLowID, coinsHigh = self.coinsHighID, purchaseApp = self.purchaseAppID })
    self.IAB:setConsumables({"coinsLow", "coinsHigh"})
    So, in the case of coinsLow and coinsHigh, I set the number of coins a user has when the purchase completes successfully. The user will them consume them over time, After the coins have run out, you can offer more.

    I execute the following:
      self.IAB:addEventListener(Event.PURCHASE_COMPLETE, self.onIABPurchaseComplete, self )
    ...
    self.IAB:purchase("coinsHigh")
    If successful then
    Event.PURCHASE_COMPLETE
    is raised:
    function InAppBilling:onIABPurchaseComplete(e)
      print "InAppBilling:onIABPurchaseComplete(e)"
      ------------------------------------------------------------------------------------------
      -- EVENT RAISED WHEN PURCHASE SUCCESSFUL
      ------------------------------------------------------------------------------------------
      local eType = e:getType()
     
      if eType == "purchaseComplete" then
        print("Purchase complete")
        self:_savePurchase(e)
     
      end
    end


    I hope this helps.
  • antixantix Member
    @simwhi, thanks! I will need to review my code. all going well I think I'll be publishing this coming week :)

    Likes: simwhi

    +1 -1 (+1 / -0 )Share on Facebook
  • simwhisimwhi Member
    @antix Nice one!! Let me know if you need further help. This took a long time to get working, but now I know how it all works.

    Likes: antix

    +1 -1 (+1 / -0 )Share on Facebook
Sign In or Register to comment.