Can someone check my config.lua looks correct for Licensing?

Hi All

I have received my Key but NOT uploaded my APK yet because I want to sign and build the package for release beforehand. When I goto test it I get a , License Error. This is my config.lua

–calculate the aspect ratio of the device:
local aspectRatio = display.pixelHeight / display.pixelWidth

application =
{
   content =
{
      width = aspectRatio > 1.5 and 320 or math.ceil( 480 / aspectRatio ),
      height = aspectRatio < 1.5 and 480 or math.ceil( 320 * aspectRatio ),
      scale = “letterBox”,
      fps = 60
},

      imageSuffix =
{
         ["@2x"] = 1.5,
         ["@4x"] = 3.0,
},

license =
{
    google =
 {
      key = “<Key inside quotes>”,
 },
   },
}

This all looks good, the only change I normally make is to allow for cached responses in case the network is unavailable using:

license = { google = { key = "\*\*\*\*GOOGLEPLAYKEY\*\*\*\*", policy = "serverManaged", }, },

If you want to test the license verification code before uploading the APK you can perform the following:

  1. Log into your Google Play account
  2. Click on the settings (cog) icon at the left of the screen
  3. Under the license testing section, enter the e-mail address of the google play account you use for testing.
  4. Change the “license test response” to the value you wish to test e.g. “LICENSED”

This will ensure that the license check code will always give this response whether the app was downloaded from Google Play or installed directly from the APK file and can be used to check all responses in your code.

The only other thing I can think to check is to ensure you have the “com.android.vending.CHECK_LICENSE” permission set in your build.settings.

Once the above is in place, the code I use to verify the license is as follows:

local licensing = require( "licensing" ) local function licensingListener( event ) local verified = event.isVerified print("Google license response: " .. event.reponse) if event.response == "Not licensed" or event.response == "Not market managed" then pirated = 1 savegame() -- Save status to config file in case user re-starts with no network elseif event.response == "Licensed" then pirated = 0 savegame() -- Save status to config file in case user re-starts with no network end end if (system.getInfo( "platformName" ) == "Android") then licensing.init( "google" ) licensing.verify( licensingListener ) end

Thanks for your input Ian, unfortunately Im getting no luck ! :frowning:

Heres my build.settings:

settings =
{
 orientation = {
  default = “portrait”,
  – supported = { “portrait”, },
  – supported = { “landscapeLeft”, “landscapeRight” },
  – supported = { “landscapeLeft”, “landscapeRight”, “portrait”, “portraitUpsideDown”, },
  supported = { “portrait” }
 },
 android =
 {
  usesPermissions =
  {
   “android.permission.INTERNET”,
   “android.permission.VIBRATE”,
   “android.permission.WRITE_EXTERNAL_STORAGE”,
   “com.android.vending.CHECK_LICENSE”,
              “com.android.vending.BILLING”,
   “android.permission.ACCESS_NETWORK_STATE”
  },
 },
 iphone =
 {
  plist =
  {
    UIAppFonts =
           {
                   “AldotheApache.ttf”,
                    “AREO.ttf”,
                   “visitor2.ttf”
              },

   UIStatusBarHidden = false,
   UIPrerenderedIcon = false, – set to false for “shine” overlay
   UIApplicationExitsOnSuspend = true,
   CFBundleIconFile = “Icon.png”,
   CFBundleIconFiles =
   {
    “Icon.png”,
    “Icon@2x.png”,
    “Icon-72.png”,
   },

  },
 },
 plugins =
{
   [“CoronaProvider.ads.vungle”] =
   {
      publisherId = “com.vungle”,
   },
   [“CoronaProvider.ads.iads”] =
   {
      publisherId = “com.coronalabs”,
      supportedPlatforms = { iphone = true },
   },
   [“CoronaProvider.ads.admob”] =
   {
      publisherId = “com.coronalabs”,
      supportedPlatforms = { android = true },
   },
},
}

Heres my main.lua

local storyboard = require( “storyboard” )
local licensing = require (“licensing”)

storyboard.purgeOnSceneChange = true

licensing.init( “google” )
 
local function licensingListener( event )
  local verified = event.isVerified
    if event.isVerified then
 

 storyboard.gotoScene( “scene_start” )
 
    else
      native.showAlert( “Licensing Failed!”, “There was a problem verifying the application, please try again.”, { “OK” } )
    end
end
 
licensing.verify( licensingListener )

 

It may be worth including the Google response code into your alert for debug purposes to see if this sheds any more light on the problem:

native.showAlert( "Licensing Failed!", "There was a problem verifying the application (" .. event.response .. "), please try again.", { "OK" } )

This all looks good, the only change I normally make is to allow for cached responses in case the network is unavailable using:

license = { google = { key = "\*\*\*\*GOOGLEPLAYKEY\*\*\*\*", policy = "serverManaged", }, },

If you want to test the license verification code before uploading the APK you can perform the following:

  1. Log into your Google Play account
  2. Click on the settings (cog) icon at the left of the screen
  3. Under the license testing section, enter the e-mail address of the google play account you use for testing.
  4. Change the “license test response” to the value you wish to test e.g. “LICENSED”

This will ensure that the license check code will always give this response whether the app was downloaded from Google Play or installed directly from the APK file and can be used to check all responses in your code.

The only other thing I can think to check is to ensure you have the “com.android.vending.CHECK_LICENSE” permission set in your build.settings.

Once the above is in place, the code I use to verify the license is as follows:

local licensing = require( "licensing" ) local function licensingListener( event ) local verified = event.isVerified print("Google license response: " .. event.reponse) if event.response == "Not licensed" or event.response == "Not market managed" then pirated = 1 savegame() -- Save status to config file in case user re-starts with no network elseif event.response == "Licensed" then pirated = 0 savegame() -- Save status to config file in case user re-starts with no network end end if (system.getInfo( "platformName" ) == "Android") then licensing.init( "google" ) licensing.verify( licensingListener ) end

Thanks for your input Ian, unfortunately Im getting no luck ! :frowning:

Heres my build.settings:

settings =
{
 orientation = {
  default = “portrait”,
  – supported = { “portrait”, },
  – supported = { “landscapeLeft”, “landscapeRight” },
  – supported = { “landscapeLeft”, “landscapeRight”, “portrait”, “portraitUpsideDown”, },
  supported = { “portrait” }
 },
 android =
 {
  usesPermissions =
  {
   “android.permission.INTERNET”,
   “android.permission.VIBRATE”,
   “android.permission.WRITE_EXTERNAL_STORAGE”,
   “com.android.vending.CHECK_LICENSE”,
              “com.android.vending.BILLING”,
   “android.permission.ACCESS_NETWORK_STATE”
  },
 },
 iphone =
 {
  plist =
  {
    UIAppFonts =
           {
                   “AldotheApache.ttf”,
                    “AREO.ttf”,
                   “visitor2.ttf”
              },

   UIStatusBarHidden = false,
   UIPrerenderedIcon = false, – set to false for “shine” overlay
   UIApplicationExitsOnSuspend = true,
   CFBundleIconFile = “Icon.png”,
   CFBundleIconFiles =
   {
    “Icon.png”,
    “Icon@2x.png”,
    “Icon-72.png”,
   },

  },
 },
 plugins =
{
   [“CoronaProvider.ads.vungle”] =
   {
      publisherId = “com.vungle”,
   },
   [“CoronaProvider.ads.iads”] =
   {
      publisherId = “com.coronalabs”,
      supportedPlatforms = { iphone = true },
   },
   [“CoronaProvider.ads.admob”] =
   {
      publisherId = “com.coronalabs”,
      supportedPlatforms = { android = true },
   },
},
}

Heres my main.lua

local storyboard = require( “storyboard” )
local licensing = require (“licensing”)

storyboard.purgeOnSceneChange = true

licensing.init( “google” )
 
local function licensingListener( event )
  local verified = event.isVerified
    if event.isVerified then
 

 storyboard.gotoScene( “scene_start” )
 
    else
      native.showAlert( “Licensing Failed!”, “There was a problem verifying the application, please try again.”, { “OK” } )
    end
end
 
licensing.verify( licensingListener )

 

It may be worth including the Google response code into your alert for debug purposes to see if this sheds any more light on the problem:

native.showAlert( "Licensing Failed!", "There was a problem verifying the application (" .. event.response .. "), please try again.", { "OK" } )