Hello!
I’m trying to set up Google IAP v3 on my game and when I call store.init(), my app crashes. I’m testing the game on my device which is a Samsung Galaxy Tab 3 and I’m using Corona Version 2014.2511 (2014.11.18).
I’ve come to the conclusion that when I call store.init( “google”, storeTransaction ) the game crashes on me. I tried following the documentation and stripped out everything else from my scene for troubleshooting, but I still get the same crash. Am I missing something in my build.settings?
scene-store.lua
local sceneName = ... local composer = require( "composer" ) local scene = composer.newScene( sceneName ) local widget = require "widget" local store local v3 = false if ( system.getInfo( "platformName" ) == "Android" ) then store = require( "plugin.google.iap.v3" ) v3 = true elseif ( system.getInfo( "platformName" ) == "iPhone OS" ) then store = require( "store" ) else native.showAlert( "Notice", "In-app purchases are not supported in the Corona Simulator.", { "OK" } ) end local function storeTransaction( event ) local transaction = event.transaction if ( transaction.state == "purchased" ) then --handle a successful transaction here print( "productIdentifier", transaction.productIdentifier ) print( "receipt", transaction.receipt ) print( "signature:", transaction.signature ) print( "transactionIdentifier", transaction.identifier ) print( "date", transaction.date ) elseif ( transaction.state == "cancelled" ) then --handle a cancelled transaction here elseif ( transaction.state == "failed" ) then --handle a failed transaction here end --tell the store that the transaction is complete! --if you're providing downloadable content, do not call this until the download has completed store.finishTransaction( event.transaction ) end store.init( "google", storeTransaction ) --------------------------------------------------------------------------------- function scene:create( event ) local sceneGroup = self.view local bg = display.newImageRect("images/panels & screens/store\_screen.png", \_S.width, \_S.height) local backBtn = widget.newButton{ defaultFile = "images/buttons/btn\_back.png", overFile = "images/buttons/btn\_back\_over.png", width = 65 \* 2, height = 25 \* 2, x = 0, y = 0, onRelease = function(event) local sceneOptions = { effect = "slideRight", time = 400, } composer.gotoScene("scene-game", sceneOptions) end, } bg.x = \_S.centerX bg.y = \_S.centerY backBtn.x = 100 backBtn.y = 50 sceneGroup:insert(bg) sceneGroup:insert(backBtn) end -- Listener setup scene:addEventListener( "create", scene ) return scene
build.settings
-- Supported values for orientation: -- portrait, portraitUpsideDown, landscapeLeft, landscapeRight settings = { orientation = { default = "landscapeRight", supported = { "landscapeLeft", "landscapeRight"} }, plugins = { ["plugin.google.iap.v3"] = { publisherId = "com.coronalabs", supportedPlatforms = { android=true } }, }, iphone = { plist = { UIStatusBarHidden = false, UIPrerenderedIcon = true, -- set to false for "shine" overlay UIAppFonts = { "BebasNeue.otf", "PoetsenOne-Regular.ttf", }, UIViewControllerBasedStatusBarAppearance = false, UIApplicationExitsOnSuspend = false, UIPrerenderedIcon = true, CFBundleIconFile = "Icon.png", CFBundleIconFiles = { "Icon.png", "Icon@2x.png", "Icon-72.png", "Icon-72@2x.png", "Icon-60.png", "Icon-76.png", "Icon-120.png", "Icon-152.png" }, } }, android = { usesPermissions = { "android.permission.INTERNET", "com.android.vending.BILLING", "android.permission.WRITE\_EXTERNAL\_STORAGE", "com.android.vending.CHECK\_LICENSE", "android.permission.ACCESS\_NETWORK\_STATE", }, }, license = { google = { key = "my key", }, }, }