One of several thousand customers reported an error in one of my apps. The error is:
java.lang.NoClassDefFoundError - android.security.MessageDigest
I don't use that class/method in my apps. The Google Mapkey must be ok because there are thousands running the same app with the same version happily. Here's the stacktrace:
java.lang.NoClassDefFoundError: android.security.MessageDigest at com.google.android.maps.KeyHelper.getSignatureFingerprint(KeyHelper.java:60) at com.google.android.maps.MapActivity.createMap(MapActivity.java:552) at com.google.android.maps.MapActivity.onCreate(MapActivity.java:422) at xx.yyy.zzzz.MyMapActivity.onCreate(MyMapActivity.java:41) at xx.yyy.zzzz.TheMap.onCreate(TheMap.java:89) at android.app.Activity.performCreate(Activity.java:4465) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981) at android.app.ActivityThread.access$600(ActivityThread.java:123) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:4424) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) at dalvik.system.NativeStart.main(Native Method)
What is this?
Thanks in advance.
Message Digest Algorithm 5 (MD5) is a cryptographic hash algorithm that can be used to create a 128-bit string value from an arbitrary length string. Although there has been insecurities identified with MD5, it is still widely used. MD5 is most commonly used to verify the integrity of files.
I spent some time looking into this problem, and I'm documenting what I've found here in the hopes that it saves other people some trouble.
The error is the result of a device manufacturer or ROM creator using an older maps library with a new version of Android. Typically, this is isolated to obscure tablets, but it could theoretically appear in other situations. It's possible to recreate this problem in an emulator using following these steps:
adb pull /system/framework/com.google.android.maps.jar <destination_folder>
You can close the emulator once you've done this.adb remount
adb push <destination_folder>/com.google.android.maps.jar /system/framework
adb reboot
but that just hung the emulator. Instead, you'll need to kill a particular process which has the same effect. In Eclipse/DDMS it will be called system_process
and you can kill it there. Alternatively, you can run this command:adb shell ps | grep system_server | awk '{print $2}' | xargs adb shell kill
This process isn't permanent. Restarting the emulator reverts it to its normal working state.
It's possible to detect this problem by getting the KeyHelper.getSignatureFingerprint()
method in the maps library via reflection and invoking it - passing a PackageManager
and your package name as arguments. Alternatively, you can trap the error in onCreate()
and load a new activity instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With