Cannot get a response code from Google Play License verification plugin

Hey everyone.

I know this seems like the easiest thing and I feel like everyone knows how to do it except me. I downloaded the “Google Play License Verification” plugin from the asset store (by Unity) and ran the test level (LVL_Example). It works, however, I cannot figure out how to USE it! I went through the code time and time again to figure out how to receive the response code i.e. LICENSED or NOT_LICENSED as in Licensing Reference  |  Android Developers All I get for a response code is “1” which I’m assuming means the application has received an answer. I see the process function is getting it’s responses from “_arg(number_here)” but I have no idea where they are coming from.

		int responseCode	= m_LVLCheck.Get<int>("_arg0");
	string message		= m_LVLCheck.Get<string>("_arg1");
	string signature	= m_LVLCheck.Get<string>("_arg2");

Can anyone help me figure out how to get the response code from Google Play?


Ok I finally figured it out and fixed the plugin. m_LVL_Received is set true a bit premature as the data hasn’t been completely filled in when it’s set to true. Change this to only set true on each return path from Process().

The example in the code doesn’t show this mistake as it continually updates the screen with the results and basically makes it look like it works. I’ve also changed the code to convert the response code string into the Android versions so 0 = LICENSED, 1 = NOT_LICENSED etc, you can find these buried in the android source code SDK.

Also change the OnGUI function to Update and get rid of all the gui stuff. Somewhere on Start initiate the LVL check (basically what it does when you press the button in the example), in Update sit and wait for the m_LVL_Received to be true. Now you can read the response code and act accordingly. Hope this helps. OH one last thing, you have to have uploaded a .apk to Google Play for this to work at all.

I’m now also having trouble with this plugin and I’d appreciate some help. I want to implement it in a game developed on Unity 4 currently being compiled with 4.7.2f1. I created a simple test application that I uploaded to Developer Console (but not published). I then side load the test app on a device for testing.

My setup:
In developer console I have:

  • apk uploaded
  • test accounts set up (same as the device I load it on)

In the inspector, Service binder points to classes_jar and I’ve copied the base-64 key into the m_PublicKey_Base64 string in the CheckLVLButton file.

Running the app, once I push the button, it doesn’t seem to collect responses. In Process() it returns after failing to collect “m_PackageName_Received”.