Unity Android and the Android Market Licensing (LVL) – a cautionary tale…

If you’ve been following this blog then you no doubt know all about my augmented reality game Zombie Room AR. What you may not know is how much of a struggle I’ve had trying to support it. If you look at the demo version in the android market you’ll see a crap  load of 1 star reviews saying the game crashes and that I suck and other idiotic comments. Over the past year I’ve been an Android developer and I know that the Star ratings and comments are on par with youtube comments, so I’ve brushed most of these off…

Unfortunately, the one thing these comments have in common is that they’re right… the game just crashes on a lot of devices… mysterious crashes that leave me scratching my head in wonder. The strangest thing is that when the game crashes, it just sort of exits. Typically when a program crashes on Android you get a box pop up with a “Force Close” or “Report” option. If you click “Report” it sends a stack trace to the developer, which will give him a clue about what the problem is. I never got one stack trace, so I had absolutely nothing to go off of. I have 4 different Android devices I test against I have not ever been able to reproduce this issue. In some cases I’ve had customers reach out to me by email asking what the deal is… and I’ve never had a good answer for it… Until today.

I want to go off base here a bit and say that up until today I had pretty much given up on AR development. For about 10 months I’ve been chasing a ghost of an issue, getting railed in my ratings, having some users send me super unfriendly emails, and I’ve been pretty much powerless to stop it. I’ve got a dozen awesome AR games that I had started planning out, but I gave up on them because I just didn’t want to deal with all the negatives from mysterious crashes…

To recap: I use Unity 3D Android Pro and my AR is powered by Qualcomm’s QDEV SDK. I’ve had tickets open with Qualcomm and Unity, both of which blamed each other and left me to figure it out myself. This isn’t a dig towards either group, well maybe a bit at Unity, but Qualcomm was actually pretty helpful… until they just couldn’t help me.

Fast forward to last week. I get an email from Qualcomm saying that they’ve re-branded QDEV to “Vuforia” and made the new improved awesome SDK generally available. I personally am not in love with the name “Vuforia”, but whatever. I’ve long thought the crashing issue had something to do with the hooks into the Camera, and I thought “Hey – why not upgrade to the new SDK and give it a shot”.

Porting to the new SDK only took about a day’s worth of effort, so I completed my task and updated both the Demo and Full versions… I then sat back and waited.  A user emails me a day later saying that it’s crashing on his device and wondered if there was anything I could do about it. My heart sank as he told me it was crashing, and he was definitely on the latest version.

Luckily for me, this user was in very good spirits and really helpful. He gave me all sorts of helpful information on how the crash was happening and he gave me a super helpful piece of information: “The game crashes/exits the moment I click on any button on the main menu”. I always figured it was when the users clicked the “Start” button which loads up an AR scene… but this was any button, most of which didn’t load an AR camera, just a typical Unity Scene… how interesting! So I start looking at everything I could be doing wrong with loading just a normal Unity scene… I’m doing everything by the book… nothing spooky or strange.. it’s all as standard as it gets.

Now that I know I’m not looking for an AR specific problem I attach several devices up to Logcat and start scraping all of the logs looking for anything at any point that could be considered out of place.  After about 10 minutes of looking I find a very suspicious line:


Permission Denial: Accessing service ComponentInfo{com.android.vending/com.google.android.finsky.services.LicensingService} from pid=2373, uid=10059 requires com.android.vending.CHECK_LICENSE

Permission Denial… Check_License? Wait a second, this error didn’t pop up until after I had pressed on the “How to Play” button… I quickly clicked all of the other buttons… every time I clicked on a button this message fires off… But my devices are working fine and loading the next screens, not exiting out…

In Unity you can set your Android Market Licensing key… I always thought this field was mandatory for the Android Market… isn’t it?

Nope.

Here’s what was happening – I wasn’t setting the CHECK_LICENSE permission in the Android Manifest.xml. Unity saw that I had my Public Key string in there and decided to go ahead and make a call, which it couldn’t perform. (Hence the permission denial). For some reason my devices (apparently just luckily) were able to skip past this issue and continue playing the game. A lot of other people’s devices hit this issue and didn’t know what to do, so it exited…

I removed the Public Key string, rebuilt the APK, updated the market place and asked my super helpful user to download the update and test. Holy freaking crap! The game is working great!!

So here I am, hopeful that the ‘crash’ issue that wasn’t a ‘crash’ issue is finally behind me. If I had any hair left I would have pulled it out long ago… And now, tired yet incredibly happy, I’m writing this up to help put it behind me… as I plan to now tackle my other AR games!

Advertisements

6 Responses to “Unity Android and the Android Market Licensing (LVL) – a cautionary tale…”


  1. 1 Alex April 25, 2012 at 10:30 pm

    This is very interesting as I am just about to release my first game and im now wondering if i should just omit putting anything in this field to begin with?

  2. 2 Timothy Johnson April 26, 2012 at 7:47 pm

    Unless you’re going to leverage the Android Licensing Service you should leave this blank.

    • 3 Alex April 30, 2012 at 9:17 am

      Hi TImothy,

      My games on the market, and it seems thaty about 30% so far have spookily similar problems to your descriptions, i.e. Crash or Freeze when loading a regular unity scene. In your opinion, do you think its worth removing the key, even as a temporary test?

      thanks for the reply, I really appreciatte it.

  3. 4 Timothy Johnson April 30, 2012 at 10:33 am

    Crashing issues are the hardest thing to troubleshoot on Android. I’d push out a new version of your app without the lvl key and see if you can get a customer to install it and give you feed back. If you have the ability to reproduce the crashes then logcat should be able to point you in the right direction of what is going wrong.

  4. 6 Gianluca June 10, 2012 at 6:13 pm

    I found this post very interesting. Thank you!


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s





%d bloggers like this: