LicensingInit is always false. Did I setup it correctly?

Hi all,
I am trying to use licensing module as shown below.
I built the apk and uploaded to Internal test track (under App releases) and then began to test using adb tool. The problem is licensingInit always returns false.
Not sure what I am doing wrong or if I need to do some other setup. Did I miss any other step? Can anyone please help me with this.

I activated the Google Play Games Services v2 plugin from marketplace as well.


    local gpgs = require( "plugin.gpgs.v2" )
    local licensing = require( "licensing" )
    local function licensingListener( event )
        if not ( event.isVerified ) then
          print("Verify: False")
        else
          print("Verify: True")
        end
    end

local licensingInit = licensing.init( "google" )
print ("licensingInit", licensingInit)
if ( licensingInit == true ) then
    licensing.verify( licensingListener )
end

build.settings:

settings= {
	plugins =
	{
			["plugin.gpgs.v2"] =
			{
					publisherId = "com.coronalabs",
					supportedPlatforms = { android=true }
			},
	},

	android =
	{
			googlePlayGamesAppId = "*************",
			usesPermissions =
			 {
					 "com.android.vending.BILLING",
					 "com.android.vending.CHECK_LICENSE",
					 "android.permission.INTERNET",
					 "android.permission.WRITE_EXTERNAL_STORAGE",
					 "android.permission.ACCESS_NETWORK_STATE",
			 },
	},
}

config.lua

application =
{
	content = {
        width = 450,
        height = 900,
        scale = "letterbox"
    },
		license =
		{
				google =
				{
						key = "long key ...",
						policy = "serverManaged"
				},
		},
}

According to Google documentation you need to publish your app to alpha or beta distribution channels. Have you tried doing that?

Note: Previously you could test an app by uploading an unpublished “draft” version. This functionality is no longer supported; instead, you must publish it to the alpha or beta distribution channel. For more information, see Draft Apps are No Longer Supported.

1 Like

Thanks for your response.
Didn’t know about that.I pushed it to Alpha and tried it again, but still getting licensingInit as false. Tried pushing it to beta as well but with the same result. Not sure what else I have done wrong.

Have you tried looking at the response codes? If you can filter out the response from adb logs, you might have a higher chance of solving the issue.

1 Like

Thanks for you response. I went through the response codes and now I tried “adb logcat” to see full log and I found this line “Unable to start service intent…”. Couldn’t understand fully, perhaps this was the issue?

I googled a bit about that, seems to be have been reported by some on stackoverflow and many answers have discussed something about changing manifest.xml or something. Don’t know if that’s the case here.

You can try to see if that’s the case. After building, open up your .apk file like a zip and edit manifest.xml. Not sure if that’s the way to go but you can try to see if it solves the issue.

1 Like

Thanks for your response. I tried opening manifest.xml, but that was not at readable. And I wasn’t sure if that would solve my problem. I was thinking my problem might be much more fundamental than I thought to be.
I went through some of the posts in this forum and found a post with some sample code for checking licensing information. I found it to be completely different from what I have used. I implemented the way OP did and I got licensing.verify() to be true :). Not sure if I did the right way because following documentation example code did not work.

post: licensing.verify - getting an error type "network" back?
Here in this post, op has used licensing module in the following way:

    local licensing = require( "licensing" )
    local function licensingListener( event )
        if not ( event.isVerified ) then
          print("Verify: False")
        else
          print("Verify: True")
        end
    end

### What I did previously.
local licensingInit = licensing.init( "google" )
if ( licensingInit == true ) then
    licensing.verify( licensingListener )
end

### OP waited for 3s before calling in licensing.verify()
licensing.init( "google" )
timer.performWithDelay(3000, 
 function (event)
  licensing.verify(licensingListener)
end
)

It made sense to wait for sometime before calling licensing.verify() because server response might not be instantaneous. However, one thing that confused me was that in the licensing documentation, the example code shown does not wait before calling licensing.verify(). I assumed that is how it is supposed to be done but sadly it isn’t working!

Moreover, OP did not even assign licensing.init( “google” ) to a local variable. But the example code in doc does assign licensing.init( “google” ) to a local variable to check for its true status before verifying it which is almost an instantaneous check . Not so useful?


If you take a look at your log, I think the reason your licensingInit variable is false is that licensing.init() was already called prior to your call that assign it to the variable.

Thanks for your response. I don’t understand why console log shows “licensing.init() was already called for google” either. I just followed the code provided in the documentation page. I checked my code and I see only this line related to initialization call: lcensing.init(“google”)?
I am using the code I pasted in the post. Could it be that the way I have implemented has some issue? I am not sure where from this warning has come from?