store.init crash using plugin.google.iap.v3

Hello all,

I have a problem with the store.init statement that crashes my app. The V3 plugin seems to be correctly loaded.

CODE:

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 iap.lua :

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 then -- 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", onGoogleInAppBilling ) 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"), message , { "Ok"},exitFromIap ) end

The crash comes up at the store.init( “google”, onGoogleInAppBilling ) statement. Verified. Removing just that line the app shows the scene and does not crash.

 

The code shows a DDMS console output like this:

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

and here the app crashes with os message after a while telling me the app is not responding etc…

Note: the licensing plugin returns isVerified==false as the app is still draft in Google Dev and has been loaded into the physical device using adb install on my Mac.

 

BTW: built using Corona public release 2393

 

Any idea ?

Thank you for any help

Stefano

Hi @st.tosi,

What does your “onGoogleInAppBilling” function look like?

Brent

Hello Brent. Thank you for your help.

Here it is 

local function onGoogleInAppBilling( event ) local transaction = event.transaction if transaction.state == "purchased" then print("Transaction succuessful!") print("productIdentifier", transaction.productIdentifier) print("receipt", transaction.receipt) print("transactionIdentifier", transaction.identifier) print("date", transaction.date) elseif transaction.state == "restored" then print("Transaction restored (from previous session)") print("productIdentifier", transaction.productIdentifier) print("receipt", transaction.receipt) print("transactionIdentifier", transaction.identifier) print("date", transaction.date) print("originalReceipt", transaction.originalReceipt) print("originalTransactionIdentifier", transaction.originalIdentifier) print("originalDate", transaction.originalDate) elseif transaction.state == "cancelled" then print("User cancelled transaction") elseif transaction.state == "failed" then print("Transaction failed, type:", transaction.errorType, transaction.errorString) else print("unknown event") end -- Once we are done with a transaction, call this to tell the store -- we are done with the transaction. -- If you are providing downloadable content, wait to call this until -- after the download completes. store.finishTransaction( transaction ) end

@Brent I also recently (few days) upgraded to Basic but I am always registered here as a Starter. Shall I stay in trouble for that ?

Stefano, do you have 

android = {

  usesPermissions = {

    “com.android.vending.BILLING”,

  },

}

 

somewhere in your build.settings?

@poon

my build.settings:

settings = { build = { neverStripDebugInfo = false }, plugins = { -- key is the name passed to Lua's 'require()' ["CoronaProvider.gameNetwork.google"] = { -- required publisherId = "com.coronalabs", supportedPlatforms = { android = true }, }, ["CoronaProvider.ads.iads"] = { publisherId = "com.coronalabs", supportedPlatforms = { iphone = true }, }, ["plugin.google.play.services"] = { publisherId = "com.coronalabs", supportedPlatforms = { android = true }, }, ["plugin.google.iap.v3"] = { publisherId = "com.coronalabs", supportedPlatforms = { android=true } }, }, excludeFiles = { all = { "DO\_NOT\_INCLUDE\_IN\_BUILD/\*", "ToDo.txt" }, iphone = { "bomb.mp3", "pop.mp3", "tap.mp3" , "cheers.mp3"}, android = {"bomb.caf", "pop.caf", "tap.caf", "cheers.caf" } }, orientation = { default = "portrait", supported = { "portrait","portraitUpsideDown" } }, iphone = { plist = { CFBundleDisplayName = "PopChase", UIApplicationExitsOnSuspend = true, UIPrerenderedIcon = true, UIStatusBarHidden = true, CFBundleIconFile = "Icon.png", CFBundleIconFiles = { "Icon.png", "Icon@2x.png", "Icon-72.png", "Icon-72@2x.png", }, }, }, android = { versionCode = "1", googlePlayGamesAppId = "21358440073", -- Your Google Play Games App Id largeHeap = true, versionCode = "10", usesPermissions = { -- queste sotto x AdMob "android.permission.INTERNET", "android.permission.ACCESS\_NETWORK\_STATE", "android.permission.READ\_PHONE\_STATE", -- queste sotto x iAp "com.android.vending.BILLING", "com.android.vending.CHECK\_LICENSE", }, usesFeatures = { { name="android.hardware.camera", required=false }, { name="android.hardware.location", required=false }, { name="android.hardware.location.gps", required=false }, } }, }

and (part of) my config.lua:

application = { content = { width = 320, height = 320\*aspectratio, scale = "letterBox", xAlign = "center", yAlign = "center", imageSuffix = { ["@2x"] = 1.5, ["@4x"] = 3.0, }, }, license = { google = { key="MIIB ...... etc. etc. etc.", policy = "serverManaged", }, }, notification = { iphone = { types = { "badge", "sound", "alert" } } } }

thanks for your help

Stefano

please find below the first messages I get from DDMS (before the crash), just after the start of my app on the physical device. You can see the hw model and os version of device.

10-11 01:24:14.976: V/Corona(20538): > Class.forName: network.LuaLoader

10-11 01:24:14.976: V/Corona(20538): < Class.forName: network.LuaLoader

10-11 01:24:14.992: V/Corona(20538): Loading via reflection: network.LuaLoader

10-11 01:24:15.000: I/Corona(20538): Platform: GT-I9003 / ARM Neon / 2.3.6 / PowerVR SGX 530 / OpenGL ES 2.0 / 2014.2393

10-11 01:24:15.226: V/Corona(20538): > Class.forName: CoronaProvider.licensing.google.LuaLoader

10-11 01:24:15.226: V/Corona(20538): < Class.forName: CoronaProvider.licensing.google.LuaLoader

10-11 01:24:15.234: V/Corona(20538): Loading via reflection: CoronaProvider.licensing.google.LuaLoader

10-11 01:24:15.539: I/Corona(20538): DEVICE=Android

10-11 01:24:15.539: I/Corona(20538): WARNING: licensing.init() was already called for google.

I do not understand the last warning on the licensing.init(). May be this is an issue related ? 

Hello, problem (at last) fixed.

See also this other thread: http://forums.coronalabs.com/topic/50156-storeavailablestores-returning-bill-with-google-yap-v3/?hl=plugin.google.iap.v3#entry267973

The thing is Google really takes much time to update their server and for any step you have to wait (hours) before getting some results.

 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 !

 

Important note: the time taken for Google to deploy a new app version uploaded as alpha or beta version may take (in my case) >10hrs !

Before that time all responses from their server  are - definitely - random: do not take any step before being sure you have the latest version downloaded into your device and provided (e.g. overnight) enough time for deployment.

 

Share and enjoy

Stefano

Hi @st.tosi,

What does your “onGoogleInAppBilling” function look like?

Brent

Hello Brent. Thank you for your help.

Here it is 

local function onGoogleInAppBilling( event ) local transaction = event.transaction if transaction.state == "purchased" then print("Transaction succuessful!") print("productIdentifier", transaction.productIdentifier) print("receipt", transaction.receipt) print("transactionIdentifier", transaction.identifier) print("date", transaction.date) elseif transaction.state == "restored" then print("Transaction restored (from previous session)") print("productIdentifier", transaction.productIdentifier) print("receipt", transaction.receipt) print("transactionIdentifier", transaction.identifier) print("date", transaction.date) print("originalReceipt", transaction.originalReceipt) print("originalTransactionIdentifier", transaction.originalIdentifier) print("originalDate", transaction.originalDate) elseif transaction.state == "cancelled" then print("User cancelled transaction") elseif transaction.state == "failed" then print("Transaction failed, type:", transaction.errorType, transaction.errorString) else print("unknown event") end -- Once we are done with a transaction, call this to tell the store -- we are done with the transaction. -- If you are providing downloadable content, wait to call this until -- after the download completes. store.finishTransaction( transaction ) end

@Brent I also recently (few days) upgraded to Basic but I am always registered here as a Starter. Shall I stay in trouble for that ?

Stefano, do you have 

android = {

  usesPermissions = {

    “com.android.vending.BILLING”,

  },

}

 

somewhere in your build.settings?

@poon

my build.settings:

settings = { build = { neverStripDebugInfo = false }, plugins = { -- key is the name passed to Lua's 'require()' ["CoronaProvider.gameNetwork.google"] = { -- required publisherId = "com.coronalabs", supportedPlatforms = { android = true }, }, ["CoronaProvider.ads.iads"] = { publisherId = "com.coronalabs", supportedPlatforms = { iphone = true }, }, ["plugin.google.play.services"] = { publisherId = "com.coronalabs", supportedPlatforms = { android = true }, }, ["plugin.google.iap.v3"] = { publisherId = "com.coronalabs", supportedPlatforms = { android=true } }, }, excludeFiles = { all = { "DO\_NOT\_INCLUDE\_IN\_BUILD/\*", "ToDo.txt" }, iphone = { "bomb.mp3", "pop.mp3", "tap.mp3" , "cheers.mp3"}, android = {"bomb.caf", "pop.caf", "tap.caf", "cheers.caf" } }, orientation = { default = "portrait", supported = { "portrait","portraitUpsideDown" } }, iphone = { plist = { CFBundleDisplayName = "PopChase", UIApplicationExitsOnSuspend = true, UIPrerenderedIcon = true, UIStatusBarHidden = true, CFBundleIconFile = "Icon.png", CFBundleIconFiles = { "Icon.png", "Icon@2x.png", "Icon-72.png", "Icon-72@2x.png", }, }, }, android = { versionCode = "1", googlePlayGamesAppId = "21358440073", -- Your Google Play Games App Id largeHeap = true, versionCode = "10", usesPermissions = { -- queste sotto x AdMob "android.permission.INTERNET", "android.permission.ACCESS\_NETWORK\_STATE", "android.permission.READ\_PHONE\_STATE", -- queste sotto x iAp "com.android.vending.BILLING", "com.android.vending.CHECK\_LICENSE", }, usesFeatures = { { name="android.hardware.camera", required=false }, { name="android.hardware.location", required=false }, { name="android.hardware.location.gps", required=false }, } }, }

and (part of) my config.lua:

application = { content = { width = 320, height = 320\*aspectratio, scale = "letterBox", xAlign = "center", yAlign = "center", imageSuffix = { ["@2x"] = 1.5, ["@4x"] = 3.0, }, }, license = { google = { key="MIIB ...... etc. etc. etc.", policy = "serverManaged", }, }, notification = { iphone = { types = { "badge", "sound", "alert" } } } }

thanks for your help

Stefano

please find below the first messages I get from DDMS (before the crash), just after the start of my app on the physical device. You can see the hw model and os version of device.

10-11 01:24:14.976: V/Corona(20538): > Class.forName: network.LuaLoader

10-11 01:24:14.976: V/Corona(20538): < Class.forName: network.LuaLoader

10-11 01:24:14.992: V/Corona(20538): Loading via reflection: network.LuaLoader

10-11 01:24:15.000: I/Corona(20538): Platform: GT-I9003 / ARM Neon / 2.3.6 / PowerVR SGX 530 / OpenGL ES 2.0 / 2014.2393

10-11 01:24:15.226: V/Corona(20538): > Class.forName: CoronaProvider.licensing.google.LuaLoader

10-11 01:24:15.226: V/Corona(20538): < Class.forName: CoronaProvider.licensing.google.LuaLoader

10-11 01:24:15.234: V/Corona(20538): Loading via reflection: CoronaProvider.licensing.google.LuaLoader

10-11 01:24:15.539: I/Corona(20538): DEVICE=Android

10-11 01:24:15.539: I/Corona(20538): WARNING: licensing.init() was already called for google.

I do not understand the last warning on the licensing.init(). May be this is an issue related ? 

Hello, problem (at last) fixed.

See also this other thread: http://forums.coronalabs.com/topic/50156-storeavailablestores-returning-bill-with-google-yap-v3/?hl=plugin.google.iap.v3#entry267973

The thing is Google really takes much time to update their server and for any step you have to wait (hours) before getting some results.

 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 !

 

Important note: the time taken for Google to deploy a new app version uploaded as alpha or beta version may take (in my case) >10hrs !

Before that time all responses from their server  are - definitely - random: do not take any step before being sure you have the latest version downloaded into your device and provided (e.g. overnight) enough time for deployment.

 

Share and enjoy

Stefano