Google Play Licensing

I am testing the Google Play Licensing functions incorporated into Corona. I currently have two non-amazon Android devices. On one (a Toshiba running Android 4.0.4) the licensing listener never gets called, yet licensing.init is not returning false. After looking into the logs I see this when it loads the app.

02-04 01:11:30.900 I/Corona  (11898): Platform: AT100 / ARM / 4.0.4 / NVIDIA Tegra / OpenGL ES 2.0 14.01002
02-04 01:11:30.990 V/Corona  (11898): > Class.forName: CoronaProvider.licensing.google.LuaLoader
02-04 01:11:30.990 V/Corona  (11898): < Class.forName: CoronaProvider.licensing.google.LuaLoader
02-04 01:11:31.070 V/Corona  (11898): Loading via reflection: CoronaProvider.licensing.google.LuaLoader
02-04 01:11:31.240 V/Corona  (11898): > Class.forName: CoronaProvider.analytics.flurry.LuaLoader
02-04 01:11:31.240 V/Corona  (11898): < Class.forName: CoronaProvider.analytics.flurry.LuaLoader
02-04 01:11:31.240 V/Corona  (11898): Loading via reflection: CoronaProvider.analytics.flurry.LuaLoader

02-04 01:11:32.290 W/System.err(11898):  at com.ansca.corona.CoronaLua.dispatchEvent(CoronaLua.java:100)
02-04 01:11:32.290 W/System.err(11898):  at CoronaProvider.licensing.google.LuaLoader$1.executeUsing(LuaLoader.java:277)
02-04 01:11:32.290 W/System.err(11898):  at com.ansca.corona.CoronaRuntimeTaskDispatcher$TaskEvent.Send(CoronaRuntimeTaskDispatcher.java:153)
02-04 01:11:32.290 W/System.err(11898):  at com.ansca.corona.events.EventManager.sendEvents(EventManager.java:219)
02-04 01:11:32.290 W/System.err(11898):  at com.ansca.corona.Controller.updateRuntimeState(Controller.java:248)
02-04 01:11:32.290 W/System.err(11898):  at com.ansca.corona.graphics.opengl.CoronaGLSurfaceView$CoronaRenderer.onDrawFrame(CoronaGLSurfaceView.java:401)
02-04 01:11:32.290 W/System.err(11898):  at com.ansca.corona.graphics.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1622)
02-04 01:11:32.290 W/System.err(11898):  at com.ansca.corona.graphics.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1377)

Can Joshua or someone else within Corona Labs determine from this log if the licensing module is failing on this device and if so why it might be happening?

Can you paste your licensing code?

Sure thing. When this is loaded on a Nexus 7 all seems fine. On the Toshiba nothing is shown. Fail or not I would expect to get the print statement if the listener was being called or the popup window if the licensing module failed to start.

[lua]

local licensing = require( “licensing” )
local gInit = licensing.init( “google” )

if gInit == false then
 native.showAlert(“Google Play”,“Failed to initialize Licensing Service!”,{“OK”})
end

local function ExitApp()
native.requestExit()  --assuming this is how we handle pirates
end

local function licensingListener( event )

 local out = event.response
 print (out)

 if not event.isVerified then
  --failed verify app from the play store, we print a message
  native.showAlert(“Google Play”,“Google Play was unable to verify the license for this app. The app will now close.”,{“OK”}, ExitApp)
 end
end

licensing.verify( licensingListener )

[/lua]

Does the Toshiba device have the Google Play store installed?

Yes. I even downloaded a few free apps from it to test it was functioning (at least from a user point of view it is).

I had forgotten I have a Nook HD here at work that now has the Google Services since Barnes and Nobles started allowing that. I loaded my app up and it seems to be failing identically to the Toshiba. Looking at the log it matches what I posted in the original post. I am currently using the lastest build (.2162). I have not experimented with other builds. I am still unsure if this is a possible Corona bug or somehow a Google Play issue.

They are both running Android 4.0.4. Not sure if that is pertinent.

I have an old Droid here. Perhaps I will try that next.

I’ve never seen an issue like that.  One possibility is that the Google Play versions on those devices don’t aren’t all the same and its having an issue with one version of the play store and not the other.  It would be best if you could supply a sample project and submit it as a bug then post the bug number here.

Ok I removed the code and started over from scratch with the sample code. It appears to work now. No idea what was wrong before.

Thank you for taking the time to help!

Can you paste your licensing code?

Sure thing. When this is loaded on a Nexus 7 all seems fine. On the Toshiba nothing is shown. Fail or not I would expect to get the print statement if the listener was being called or the popup window if the licensing module failed to start.

[lua]

local licensing = require( “licensing” )
local gInit = licensing.init( “google” )

if gInit == false then
 native.showAlert(“Google Play”,“Failed to initialize Licensing Service!”,{“OK”})
end

local function ExitApp()
native.requestExit()  --assuming this is how we handle pirates
end

local function licensingListener( event )

 local out = event.response
 print (out)

 if not event.isVerified then
  --failed verify app from the play store, we print a message
  native.showAlert(“Google Play”,“Google Play was unable to verify the license for this app. The app will now close.”,{“OK”}, ExitApp)
 end
end

licensing.verify( licensingListener )

[/lua]

Does the Toshiba device have the Google Play store installed?

Yes. I even downloaded a few free apps from it to test it was functioning (at least from a user point of view it is).

Hi,

Would it be possible to post your new code that works?

Thanks

T.

Sure. It’s pretty basic. I put this in a separate lua file called googleplay.lua.

local licensing = require( "licensing" ) local gInit = licensing.init( "google" ) local function licensingListener( event ) &nbsp;local v = event.isVerified &nbsp;if v then &nbsp;&nbsp;-- ALL GOOD &nbsp;else &nbsp;&nbsp;native.showAlert("Google Play","Failed to verify app license. An internet connection is required. Check your connection and try again!",{"OK"}, function() native.requestExit() end) &nbsp;end end local function GoogleVerify() &nbsp;licensing.verify( licensingListener ) end if gInit == true then &nbsp;GoogleVerify() end &nbsp;

I had forgotten I have a Nook HD here at work that now has the Google Services since Barnes and Nobles started allowing that. I loaded my app up and it seems to be failing identically to the Toshiba. Looking at the log it matches what I posted in the original post. I am currently using the lastest build (.2162). I have not experimented with other builds. I am still unsure if this is a possible Corona bug or somehow a Google Play issue.

They are both running Android 4.0.4. Not sure if that is pertinent.

I have an old Droid here. Perhaps I will try that next.

I’ve never seen an issue like that.  One possibility is that the Google Play versions on those devices don’t aren’t all the same and its having an issue with one version of the play store and not the other.  It would be best if you could supply a sample project and submit it as a bug then post the bug number here.

Ok I removed the code and started over from scratch with the sample code. It appears to work now. No idea what was wrong before.

Thank you for taking the time to help!

Hi,

Would it be possible to post your new code that works?

Thanks

T.

Sure. It’s pretty basic. I put this in a separate lua file called googleplay.lua.

local licensing = require( "licensing" ) local gInit = licensing.init( "google" ) local function licensingListener( event ) &nbsp;local v = event.isVerified &nbsp;if v then &nbsp;&nbsp;-- ALL GOOD &nbsp;else &nbsp;&nbsp;native.showAlert("Google Play","Failed to verify app license. An internet connection is required. Check your connection and try again!",{"OK"}, function() native.requestExit() end) &nbsp;end end local function GoogleVerify() &nbsp;licensing.verify( licensingListener ) end if gInit == true then &nbsp;GoogleVerify() end &nbsp;