store.availableStores returning bill with Google yap v3

@st.tosi I see you as Basic.  @david.hunt15, I wouldn’t worry about the forums display, it might take a while to sync up.  If you’re getting Pro features while using the Simulator, you should be good to go.

@st.tosi, generally to use IAP, you have to at some point let Google Play know the App you want to use with IAP.  Generally you have to set everything up and upload an “Alpha” build so it can see the keystore and some other things and verify the licensing.   Once that’s done, you should be able to load versions to your test device as long as the keystore and license key’s all match whats in your alpha build.

Rob

@Rob Problem seemed to be fixed. I had to publish the alpha test version as suggested. 

The thing is the app run smoothly once ! Suspending (not exiting) the app and then resuming… same problem: the store.init crashes agin.

I’ve tried to reload the app into the device (using Mac). Same problem still persists.

I am desperate. In the Google Dev Console all test services are published: alpha test only. Not for production.

?

Edit update:

Cheers ! I had to activate (me) on device as an alpha tester. i.e.

  1. establish a Google community (!) for alpha (and) beta testing

  2. sign up myself to the community

  3. getting the app link from the Google Developer Console/Apk/TestAlpha/Manage list of testers

  4. on device: click the link and activate myself as an alpha tester

  5. install the app on device from Play Store, on device (as I activated myself now I see the app in the Store)

  6. strongly crossing fingers run the app: finally it works

Tried to de-install and re-install, on device, from the Store again: it keeps working !!! Unbelievable !

Tried to de-install and re-install again form my Mac (adb install etc): it’s incredible but it still keeps up working smoothly !

Comment1: the first time (see please the first part of this post) the app was run ok without having activated me as an alpha tester. Something weird with their server. It then stopped working again. That pushed me in depression.

Comment2: I was convinced Apple were messy: I had not yet experience on Google store handling. A nightmare !

Thank you anyway for your support.

Stefano

We are sometimes at the mercy of the tools we use.  For instance on Android when you’re calling the IAP stuff, we are not in Corona controlled space any more but inside another activity on the device, like Google Play.  Some times all we can do is pass back the error we get.  When running adb logcat, when working with things like GPGS, IAP etc. it’s best to not filter for just Corona messages since you will miss anything coming from other Activities you are working with.

Rob

I submitted a request via the wufoo form, but these docs should be updated to switch the order so that the check for apple comes after the check for v3/google … else it craps out

http://docs.coronalabs.com/daily/guide/monetization/IAP/index.html

Hi,  Im getting the “attempt to index field ‘availableStores’ (a nil value)” too when running on android.

Looking at what you put @dchan, I dont understand how that fixes the issues as you are still trying to access the method when you check store.availableStores.apple

Maybe I am missing something obvious?  Could someone explain what the solution is please :slight_smile:

Thanks 

this is what i have:

local store local v3 = false if ( system.getInfo( "platformName" ) == "Android" ) then store = require( "plugin.google.iap.v3" ) v3 = true print("Using Google Play") elseif ( system.getInfo( "platformName" ) == "iPhone OS" ) then store = require( "store" ) print("Using iTunes") else print("In-app purchases are not supported in the Corona Simulator.") end

--utilize 'store.availableStores' function: if store ~= nil then if ( store.availableStores.apple ) then currentProductList = appleProductList store.init( "apple", storeTransaction ) elseif ( v3 == true or store.availableStores.google ) then currentProductList = googleProductList store.init( "google", storeTransaction ) else print( "In-app purchases are not supported on this system/device." ) end end

You should change the logic a bit. Something like this should work:

if store ~= nil then if ( v3 == true ) then -- use Google IAB V3 currentProductList = googleProductList store.init( "google", storeTransaction ) elseif ( store.availableStores.apple ) then currentProductList = appleProductList store.init( "apple", storeTransaction ) else print( "In-app purchases are not supported on this system/device." ) end end

Like you have noted, the previous example given tries to access store.availableStores which isn’t always present.

In the adjusted logic above I have only included v3 == true since store.availableStores.google doesn’t exist in the v3 version of the plugin.

thanks for the reply,  @ingemar.

I tried that but it still didn’t work for me.  I ended up doing this in the end which seems to work but doesn’t feel very neat.

if (v3 == true) then currentProductList = googleProductList store.init( "google", storeTransaction ) elseif ( store.availableStores ~= nil ) then if ( store.availableStores.apple ) then currentProductList = appleProductList store.init( "apple", storeTransaction ) end else print( "In-app purchases are not supported on this system/device." ) end

@david

The code I posted should work. I tested it in a simple test project and it handles Apple and Google V3 without crashing.

What was the problem you saw?

Hi all,

I have a problem similar to yours, perhaps worse.

With V3, on a physical device, GalaxyS GT-I9003 (quite old, Android 2.3.6) the code below crashes the app ( ! i.e. stops and freezes the display. App remains dead with display freezed). After a while an Android message ‘the app is no longer responding’ glows and I may terminate the app.

This same code works smooth in iOS.

In build.settings among plugins=

["plugin.google.iap.v3"] =        {             publisherId = "com.coronalabs",             supportedPlatforms = { android=true }         },.

And among android=:

usesPermissions =         {           "com.android.vending.BILLING",           --"com.android.vending.CHECK\_LICENSE",         },

In the scene:create I have:

if ( device.isAndroid ) then        store = require( "plugin.google.iap.v3" )         v3 = true         infoLabel.text="Google store plugin  load"     elseif ( device.isApple ) then         infoLabel.text="Apple store library load"         store = require( "store" )     end

if  (store~=nil) then              --utilize 'store.availableStores' function:             if device.isApple and store.availableStores.apple then                 currentProductList = appleProductList                 store.init( "apple", storeTransaction )             --elseif ( v3 == true or store.availableStores.google ) then             elseif ( v3 == true ) then                 currentProductList = googleProductList                 store.init( "google", storeTransaction )             else                 local message= "In-app purchases are not supported on this system/device."                 native.showAlert( system.getInfo("appName"), message , { "Ok"},exitFromIap )             end         end         if device.isApple and ( not store.canMakePurchases)  then             message=translations.localize("warnpurchasenotenabled", "language")             native.showAlert( system.getInfo("appName"), message , { "Ok"},exitFromIap )         end

I have removed the store.availableStores.google according to this conversation. But the problem still exists.

Do you have any idea ?

Thank you.

Stefano

@stefano
I’m starting to suspect that the Google Play Store app you have installed on the device may not support IAB V3.
If possible try to see if you can update it.

Also, to see what’s going on, connect your device to your computer and do a ‘adb logcat’ to see what’s crashing.

The log cat says:

10-08 18:06:47.695: V/Corona(5185): > Class.forName: plugin.google.iap.v3.LuaLoader

10-08 18:06:47.703: V/Corona(5185): < Class.forName: plugin.google.iap.v3.LuaLoader

10-08 18:06:47.703: V/Corona(5185): Loading via reflection: plugin.google.iap.v3.LuaLoader

and then stops !

I have the Google Play Store 4.9.13 and Google Play Games 2.0.13

Does it make any sense ?

BTW: thank you for your help.

Stefano

Does the device have the Google Play app installed (and latest version)?    Opps never mind. I didn’t see the message below the code.

Rob

@Rob

Hello, thanks for any help as well !

Hi ingemar - I tried it again and now it works as you said… very strange - I reverted to my older version so it is the exact same code that didn’t work before.  Maybe I forgot to save my file before building haha either way - that part now work!  cheers :slight_smile:

@st.tosi 

I had this problem too but for me, adding the licence key from google dev console resolved it. 

it does not mention it in this article http://docs.coronalabs.com/daily/guide/monetization/IAP/index.html

but it does in this one :   http://docs.coronalabs.com/daily/plugin/google-iap-v3/

(it’s a plugin so I don’t think it matters but i’m on the latest daily build 2014.2458)

Project Configuration

To use Google IAP v3, the license table must be added to the project config.lua file. Inside this table, the key value should be set to the corresponding key obtained from the Google Play Developer Console.

application = { license = { google = { key = "Your key", }, }, }

@rob - off on a complete tangent but…  I upgraded to pro recently but it still says starter under my name? anything to worry about? 

@David

Thanks a lot ! You fixed this issue with your answer. Appreciated.

I missed to add the license key. It is now loading the plugin.

The thing is now it is crashing a little bit later (as usual: Google only. Apple goes) at the store.init call. Full crash: device blocked up. Message on device glows to terminate the not responding app etc.

Code:

in main.lua:

if (device.isAndroid) then print("DEVICE=Android") local licensing = require( "licensing" ) licensing.init( "google" ) local function licensingListener( event ) local verified = event.isVerified print( "address", event.address ) print("name", event.name) print("provider", event.provider) print("isVerified", event.isVerified) print("isError", event.isError) print("errorType", event.errorType) print("response", event.response) if not event.isVerified then --failed verify app from the play store, we print a message print( "Binary NOT BEING VERIFIED from the Google App Store !" ) --native.requestExit() --assuming this is how we handle pirates else print( "Google app has been verified" ) end end licensing.verify( licensingListener ) end

in the InAppPurchase .lua file:

if ( device.isAndroid ) then store = require( "plugin.google.iap.v3" ) v3 = true message="Google store plugin loaded" elseif ( device.isApple ) then message="Apple store library loaded" store = require( "store" ) end if (store ~= nil) then print ("STORE loaded: ".. message) else print ("STORE NOT loaded: ".. message) end

if (store~=nil) then --utilize 'store.availableStores' function: if device.isApple and store.availableStores.apple then currentProductList = appleProductList store.init( "apple", storeTransaction ) --elseif ( v3 == true or store.availableStores.google ) then elseif ( v3 == true ) then currentProductList = googleProductList store.init( "google", storeTransaction ) print ("Google store initialized") else local message= "In-app purchases are not supported on this system/device." native.showAlert( system.getInfo("appName"), message , { "Ok"},exitFromIap ) end end if device.isApple and ( not store.canMakePurchases) then message=translations.localize("warnpurchasenotenabled", "language") native.showAlert( system.getInfo("appName&nbsp;

The crash comes up at the store.init statement. Verified.

The above code prints in the DDMS console:

10-10 18:38:30.859: V/Corona(21662): > Class.forName: CoronaProvider.gameNetwork.google.LuaLoader

10-10 18:38:30.859: V/Corona(21662): < Class.forName: CoronaProvider.gameNetwork.google.LuaLoader

10-10 18:38:30.859: V/Corona(21662): Loading via reflection: CoronaProvider.gameNetwork.google.LuaLoader

10-10 18:38:35.656: I/Corona(21662): address nil

10-10 18:38:35.656: I/Corona(21662): name licensing

10-10 18:38:35.656: I/Corona(21662): provider google

10-10 18:38:35.656: I/Corona(21662): isVerified false

10-10 18:38:35.656: I/Corona(21662): isError true

10-10 18:38:35.656: I/Corona(21662): errorType configuration

10-10 18:38:35.656: I/Corona(21662): response Not market managed

10-10 18:38:35.656: I/Corona(21662): Binary NOT BEING VERIFIED from the Google App Store !

10-10 18:38:44.757: V/Corona(21662): > Class.forName: plugin.google.iap.v3.LuaLoader

10-10 18:38:44.765: V/Corona(21662): < Class.forName: plugin.google.iap.v3.LuaLoader

10-10 18:38:44.765: V/Corona(21662): Loading via reflection: plugin.google.iap.v3.LuaLoader

10-10 18:38:44.773: I/Corona(21662): STORE loaded: Google store plugin  loaded

The app does not come from the market: it obviously comes from my adb install command  of my Mac. Anything related to that ?

Any idea ?

@Rob I also recently (few days) upgraded to Basic but I am always registered here as a Starter: same comment of David. Shall I stay in trouble for that ?

@st.tosi I see you as Basic.  @david.hunt15, I wouldn’t worry about the forums display, it might take a while to sync up.  If you’re getting Pro features while using the Simulator, you should be good to go.

@st.tosi, generally to use IAP, you have to at some point let Google Play know the App you want to use with IAP.  Generally you have to set everything up and upload an “Alpha” build so it can see the keystore and some other things and verify the licensing.   Once that’s done, you should be able to load versions to your test device as long as the keystore and license key’s all match whats in your alpha build.

Rob

@Rob Problem seemed to be fixed. I had to publish the alpha test version as suggested. 

The thing is the app run smoothly once ! Suspending (not exiting) the app and then resuming… same problem: the store.init crashes agin.

I’ve tried to reload the app into the device (using Mac). Same problem still persists.

I am desperate. In the Google Dev Console all test services are published: alpha test only. Not for production.

?

Edit update:

Cheers ! I had to activate (me) on device as an alpha tester. i.e.

  1. establish a Google community (!) for alpha (and) beta testing

  2. sign up myself to the community

  3. getting the app link from the Google Developer Console/Apk/TestAlpha/Manage list of testers

  4. on device: click the link and activate myself as an alpha tester

  5. install the app on device from Play Store, on device (as I activated myself now I see the app in the Store)

  6. strongly crossing fingers run the app: finally it works

Tried to de-install and re-install, on device, from the Store again: it keeps working !!! Unbelievable !

Tried to de-install and re-install again form my Mac (adb install etc): it’s incredible but it still keeps up working smoothly !

Comment1: the first time (see please the first part of this post) the app was run ok without having activated me as an alpha tester. Something weird with their server. It then stopped working again. That pushed me in depression.

Comment2: I was convinced Apple were messy: I had not yet experience on Google store handling. A nightmare !

Thank you anyway for your support.

Stefano

We are sometimes at the mercy of the tools we use.  For instance on Android when you’re calling the IAP stuff, we are not in Corona controlled space any more but inside another activity on the device, like Google Play.  Some times all we can do is pass back the error we get.  When running adb logcat, when working with things like GPGS, IAP etc. it’s best to not filter for just Corona messages since you will miss anything coming from other Activities you are working with.

Rob

I submitted a request via the wufoo form, but these docs should be updated to switch the order so that the check for apple comes after the check for v3/google … else it craps out

http://docs.coronalabs.com/daily/guide/monetization/IAP/index.html