I’ve been successfully using the Unity Google Play License Verification plugin for about a year. I recently picked up a Samsung Galaxy S2 to troubleshoot some shader issues, but before I could even start on those, I found that my game fails to launch on that device, locking up as soon as it attempts to load that licensing plugin.
The logcat error is:
D/dalvikvm( 4229): DexOpt: sleeping on flock(/data/data/com.PanicEnsuesSoftware.
CrashDive/cache/com.PanicEnsuesSoftware.CrashDive/odex/classes.dex)
I’m not sure where to go with this error; I’ve tried with the latest update to the plugin (Feb 2015) as well as an older version.
The device is running Android 4.0.3; all other devices I’ve tested on continue to work fine (though none of them are running 4.0.3).
After more experimentation, I’ve determined this freeze has nothing to do with the LVL plugin; but that on this device (Galaxy S2), calling dalvik.system.DexClassLoader (or at least calling it as a new AndroidJavaObject from Unity) fails about 50-75% of the time. The debug output halts at D/dalvikvm( 6778): DexOpt: --- BEGIN 'classes.jar' (bootstrap=0) ---
If I kill the app and launch it a couple more times, it eventually will succeed and report D/dalvikvm( 6778): DexOpt: --- END 'classes.jar' (success) ---
I’ve tried using both internal and storage memory to cache the classes.jar I’m loading; makes no difference.
I’m still at a loss as to how to avoid this freeze, but will keep digging.
And will definitely not be buying any Samsung devices for personal use in the future.
Scott, just looking for some quick guidance on this license verification plugin that you are using. Do I need to do anything else besides importing this plugin? I am building my apk from unity (not android studio/eclipse/etc), but do I need to do post processing? Thanks -Valerie
Valerie,
While it’s not 100% plug and play, it does the vast majority of the work for you.
Documentation is pretty scarce, you have to look through the scripts that come with it to see what items are just templates that you need to replace with your own game’s data.
You’ll also need to write the code for handling what you want your app to do when a license check fails.
I added the plugin a couple years ago, but from what I recall its default behavior is to check against the license server every time you call its code. I wanted people to be able to play offline, so I cach the results it returns in an encrypted local file, and only require re-checking against the server about once a month.
I can’t thank you enough for the information and support. You are the only one who took the time to reply and I posted several requests for help. So thank you very much. I managed to get it all working now. I wasn’t sure how everyone was implementing it, whether checking every time the app ran, or caching or what, so thanks for the feedback on your specific implementation. I think I will do the same as you and just check every 30 days.
For those still looking for help, here’s what I did.
Import the asset into unity
Added the example cs as a component to my main canvas (commented out the GUI stuff and added the few lines of code which executed on a GUI button into the Start() method).
Build from Unity (check the Google Android Project) in build settings
import project into Android studio
in terminal execute steps to build google play app verification library
from android studio → project structure add import module and navigate to assets/googleplaylicenseverification/licenseverification and click ok
BTW, due to the original problem that spawned this thread, the license check plugin will cause your app to freeze about 50% of the time on a few devices (Samsung phones/tablets running a specific build of Android 4.0.3).
This is due to a race condition in Android’s DexClassLoader, between the code to decompress a Classes.jar, and the code to read that extracted data.
Sometimes the decompression code will “win” (finish first) and everything will work out fine. Other times, the classLoader will attempt to read the extracted files while they’re still being decompressed (so are locked) and will fail.
Luckily, there aren’t a ton of these devices out there (and given Samsung’s churn rate, fewer every day :). When it does freeze, users can force-kill the app and try again.