dalvik.system.BaseDexClassLoader.findClass 中的 java.lang.ClassNotFoundException
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15686593/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
java.lang.ClassNotFoundException in dalvik.system.BaseDexClassLoader.findClass
提问by Mark Molina
This error is driving me crazy. My app crashes at startup when downloaded from the Google Play Store with the error:
这个错误让我发疯。从 Google Play 商店下载时,我的应用程序在启动时崩溃并显示以下错误:
java.lang.ClassNotFoundException
in dalvik.system.BaseDexClassLoader.findClass
My app doesn't crash when build from eclipse on our two devices. However a month ago a client used his phone to build our app in and then it also crashed on startup. I ignored the problem then because it was working on our devices and figured it had something to do with Google Map keys or Keystore.
在我们的两台设备上从 eclipse 构建时,我的应用程序不会崩溃。然而,一个月前,一位客户使用他的手机构建了我们的应用程序,然后它在启动时也崩溃了。我当时忽略了这个问题,因为它在我们的设备上运行,并认为它与谷歌地图键或密钥库有关。
Now it turns out our app crashes on every device when downloaded from the Play Store. I understand that there isn't an easy way to solve this problem but a push in the right direction would be appreciated.
现在,当我们从 Play 商店下载时,我们的应用程序在每台设备上都崩溃了。我知道没有一个简单的方法来解决这个问题,但是朝着正确的方向推动将不胜感激。
I also find it hard to debug this problem because the app works great when build from eclipse on our devices!
我还发现很难调试这个问题,因为在我们的设备上从 eclipse 构建时,该应用程序运行良好!
Here is the complete error log that I reported:
这是我报告的完整错误日志:
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.denederlandsewateren.winkeloord/com.denederlandsewateren.views.StartScreenActivity}: java.lang.ClassNotFoundException: com.denederlandsewateren.views.StartScreenActivity
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2099)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2210)
at android.app.ActivityThread.access0(ActivityThread.java:142)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1208)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4931)
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:791)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:558)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: com.denederlandsewateren.views.StartScreenActivity
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at android.app.Instrumentation.newActivity(Instrumentation.java:1053)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2090)
... 11 more
Again I dont except a straight forward answer to this problem but maybe somebody can shed some light on this problem provided with this error log.
同样,我不只是直接回答这个问题,但也许有人可以通过这个错误日志来解释这个问题。
EDIT
编辑
Here is the Manifest file if thats helpfull:
如果有帮助,这是清单文件:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.xxxx.xxxxx"
android:versionCode="1"
android:versionName="1.0" >
<permission
android:name="com.xxxxx.xxxxx.MAPS_RECEIVE"
android:protectionLevel="signature" />
<permission
android:name="com.xxxxx.xxxxx.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="my_app_package.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="com.xxxxxx.xxxxx.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.VIBRATE" />
<application
android:allowBackup="true"
android:icon="@drawable/app_icon"
android:label="@string/app_name"
android:theme="@style/Theme.Sherlock" >
<service android:name="com.xxxxxx.xxxxx.GCMIntentService" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="xxxxxxxx" />
<receiver
android:name="com.google.android.gcm.GCMBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.xxxxxx.xxxxxxx" />
</intent-filter>
</receiver>
<activity
android:name="com.xxxxx.xxxxx.MainActivity"
android:label="@string/app_name"
android:screenOrientation="portrait">
<!--<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter> -->
</activity>
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="@string/app_id" />
<activity android:name="com.facebook.LoginActivity" >
</activity>
<activity
android:name="com.xxxxxx.xxxxxx.StartScreenActivity"
android:label="@string/app_name"
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
EDIT
编辑
Added the verbose log when installing the app on the device
在设备上安装应用程序时添加了详细日志
03-30 17:56:28.554: D/dalvikvm(5150): GC_FOR_ALLOC freed 233K, 68% free 2639K/8195K, paused 13ms, total 13ms
03-30 17:56:28.574: I/dalvikvm-heap(5150): Grow heap (frag case) to 26.682MB for 16777232-byte allocation
03-30 17:56:28.594: D/dalvikvm(5150): GC_CONCURRENT freed <1K, 23% free 19022K/24647K, paused 2ms+9ms, total 21ms
03-30 17:56:29.114: D/dalvikvm(5150): GC_FOR_ALLOC freed 0K, 23% free 19022K/24647K, paused 15ms, total 15ms
03-30 17:56:29.129: I/dalvikvm-heap(5150): Grow heap (frag case) to 35.681MB for 9437200-byte allocation
03-30 17:56:29.169: D/dalvikvm(5150): GC_CONCURRENT freed 0K, 17% free 28238K/33927K, paused 2ms+2ms, total 38ms
03-30 17:56:29.254: D/libEGL(5150): loaded /system/lib/egl/libEGL_mali.so
03-30 17:56:29.259: D/libEGL(5150): loaded /system/lib/egl/libGLESv1_CM_mali.so
03-30 17:56:29.259: D/libEGL(5150): loaded /system/lib/egl/libGLESv2_mali.so
03-30 17:56:29.284: D/OpenGLRenderer(5150): Enabling debug mode 0
03-30 17:56:32.154: D/KEY(5150): UUID
03-30 17:56:32.179: I/System.out(5150): UUID: xxxxxxxxxxxxxx
03-30 17:56:32.179: E/SerializeObject(5150): FileNot Found in ReadSettings filename = xxxxx.dat
03-30 17:56:32.184: D/GCMRegistrar(5150): resetting backoff for com.xxxxx.xxxxx
03-30 17:56:32.214: V/GCMRegistrar(5150): Registering app com.xxxxx.xxxxx of senders 752727514714
03-30 17:56:32.214: D/KEY(5150): pushEnabled
03-30 17:56:32.324: V/SlidingMenu(5150): setting padding!
03-30 17:56:32.394: W/AllCapsTransformationMethod(5150): Caller did not enable length changes; not transforming text
03-30 17:56:32.394: W/AllCapsTransformationMethod(5150): Caller did not enable length changes; not transforming text
03-30 17:56:32.394: W/AllCapsTransformationMethod(5150): Caller did not enable length changes; not transforming text
03-30 17:56:32.409: W/AllCapsTransformationMethod(5150): Caller did not enable length changes; not transforming text
03-30 17:56:32.414: W/AllCapsTransformationMethod(5150): Caller did not enable length changes; not transforming text
03-30 17:56:32.414: W/AllCapsTransformationMethod(5150): Caller did not enable length changes; not transforming text
03-30 17:56:32.424: W/AllCapsTransformationMethod(5150): Caller did not enable length changes; not transforming text
03-30 17:56:32.424: W/AllCapsTransformationMethod(5150): Caller did not enable length changes; not transforming text
03-30 17:56:32.429: W/AllCapsTransformationMethod(5150): Caller did not enable length changes; not transforming text
03-30 17:56:32.434: W/AllCapsTransformationMethod(5150): Caller did not enable length changes; not transforming text
03-30 17:56:32.434: W/AllCapsTransformationMethod(5150): Caller did not enable length changes; not transforming text
03-30 17:56:32.434: W/AllCapsTransformationMethod(5150): Caller did not enable length changes; not transforming text
03-30 17:56:32.459: V/CustomViewBehind(5150): behind INVISIBLE
03-30 17:56:36.894: D/dalvikvm(5150): GC_CONCURRENT freed 20031K, 58% free 15574K/36551K, paused 4ms+7ms, total 49ms
03-30 17:56:36.894: D/dalvikvm(5150): WAIT_FOR_CONCURRENT_GC blocked 31ms
03-30 17:56:37.504: I/System.out(5150): VaarApp ID: 5
03-30 17:56:37.534: I/Choreographer(5150): Skipped 122 frames! The application may be doing too much work on its main thread.
03-30 17:56:37.539: V/GCMBroadcastReceiver(5150): onReceive: com.google.android.c2dm.intent.REGISTRATION
03-30 17:56:37.544: V/GCMBroadcastReceiver(5150): GCM IntentService class: com.xxxxx.xxxxx.GCMIntentService
03-30 17:56:37.549: V/GCMBaseIntentService(5150): Acquiring wakelock
03-30 17:56:37.794: V/GCMBaseIntentService(5150): Intent service name: GCMIntentService-DynamicSenderIds-1
03-30 17:56:37.794: E/GCMRegistrar(5150): internal error: retry receiver class not set yet
03-30 17:56:37.794: V/GCMRegistrar(5150): Registering receiver
03-30 17:56:37.799: D/GCMBaseIntentService(5150): handleRegistration: registrationId = xxxxxxxxx-xxxxxxxx-xxxxxxxx-xxxxxx-xxxxx-xxxx, error = null, unregistered = null
03-30 17:56:37.799: D/GCMRegistrar(5150): resetting backoff for com.xxxxx.xxxxx
03-30 17:56:37.799: V/GCMRegistrar(5150): Saving regId on app version 1
03-30 17:56:37.829: V/GCMBaseIntentService(5150): Releasing wakelock
03-30 17:56:39.169: D/dalvikvm(5150): GC_CONCURRENT freed 2248K, 52% free 17830K/36551K, paused 6ms+12ms, total 95ms
03-30 17:56:39.169: D/dalvikvm(5150): WAIT_FOR_CONCURRENT_GC blocked 12ms
03-30 17:56:39.174: D/dalvikvm(5150): WAIT_FOR_CONCURRENT_GC blocked 48ms
03-30 17:56:41.164: I/dalvikvm(5150): Jit: resizing JitTable from 4096 to 8192
03-30 17:56:42.229: D/dalvikvm(5150): GC_CONCURRENT freed 4265K, 49% free 18778K/36551K, paused 3ms+6ms, total 58ms
03-30 17:56:42.229: D/dalvikvm(5150): WAIT_FOR_CONCURRENT_GC blocked 41ms
03-30 17:56:42.234: D/dalvikvm(5150): WAIT_FOR_CONCURRENT_GC blocked 46ms
03-30 17:57:51.759: D/dalvikvm(5150): GC_CONCURRENT freed 5476K, 49% free 18775K/36551K, paused 21ms+6ms, total 196ms
采纳答案by Mark Molina
So it was indeed ProGuard that was stripping code from my project. I use ActionBarSherlock and facebook and this is what I added so it would work:
所以确实是 ProGuard 从我的项目中剥离了代码。我使用 ActionBarSherlock 和 facebook,这是我添加的内容,因此它可以工作:
# ActionBarSherlock
-keep class android.support.** { *; }
-keep interface android.support.** { *; }
-keep class com.actionbarsherlock.** { *; }
-keep interface com.actionbarsherlock.** { *; }
# Keep line numbers to alleviate debugging stack traces
-renamesourcefileattribute SourceFile
-keepattributes SourceFile,LineNumberTable
This for facebook:
这是脸书:
-keepclassmembers class * implements java.io.Serializable
{
private static final java.io.ObjectStreamField[] serialPersistentFields;
private void writeObject(java.io.ObjectOutputStream);
private void readObject(java.io.ObjectInputStream);
java.lang.Object writeReplace();
java.lang.Object readResolve();
}
回答by Regis_AG
Right click on your project folder => Properties => Java Build Path => Order and Export => check the box "Android Private Libraries" if not checked. And it works !
右键单击您的项目文件夹 => 属性 => Java 构建路径 => 订购和导出 => 如果未选中,请选中“Android 私有库”框。它有效!
回答by George
Well, I'd suggest you focus at the difference between the build you are doing from eclipse and the build you are providing to the Play Store.
好吧,我建议您关注从 eclipse 进行的构建与提供给 Play 商店的构建之间的区别。
If you can reproduce the error you see from the playstore, while building it with eclipse and testing it, you will surely find the answer.
如果你能重现你从 playstore 看到的错误,同时用 eclipse 构建它并测试它,你一定会找到答案。
What I can think of is the certificates that the app gets signed, but it doesn't seem to be it. However you should think more about what is the difference between the two .apk's - the developer build and the build for playstore.
我能想到的是应用程序获得签名的证书,但似乎不是。但是,您应该更多地考虑两个 .apk 之间的区别 - 开发人员版本和 Playstore 版本。
As .apk are basically archives, you can unzip them both, see differences between them. You should use a dedexer to try and decompile the two instances of classes.dex (see decompiling DEX into Java sourcecode). It will likely be highly obfuscated code, but you should look for missing classes or something like that.
由于 .apk 基本上是档案,您可以将它们都解压缩,查看它们之间的差异。您应该使用 dedexer 尝试反编译 classes.dex 的两个实例(请参阅将DEX 反编译为 Java 源代码)。它可能是高度混淆的代码,但您应该寻找丢失的类或类似的东西。
Hope you get it right.
希望你做对了。