匿名和静态嵌套的 NoClassDefFoundError 类
NoClassDefFoundError on anonymous and static nested classes
我在我的应用程序中的嵌套静态和匿名 classes 上遇到了 NoClassDefFoundError。关键是,这种情况并非发生在我测试过的每台设备上。我已经阅读了很多 Whosebug 和 google 试图解决这个问题,但我仍然不明白为什么它会在 Zenphone 5 和 Galaxy Tab E (android 4.4.4) 上发生但在 nexus 7/ 上从未发生过10 或在具有 Android 5+.
的任何其他设备上
我还尝试将所有嵌套的 classes 从基础 class 移到它们自己的 .java 文件中,这有帮助,但我想了解根本问题和修复它。
P.S。有可能,这个问题与 multidex 支持有关吗?
UPD 1
LogCat:
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/CrashlyticsCore: Failed to execute task.
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/CrashlyticsCore: java.util.concurrent.TimeoutException
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/CrashlyticsCore: at java.util.concurrent.FutureTask.get(FutureTask.java:173)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/CrashlyticsCore: at com.crashlytics.android.core.CrashlyticsExecutorServiceWrapper.executeSyncLoggingException(CrashlyticsExecutorServiceWrapper.java:44)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/CrashlyticsCore: at com.crashlytics.android.core.CrashlyticsUncaughtExceptionHandler.uncaughtException(CrashlyticsUncaughtExceptionHandler.java:245)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/CrashlyticsCore: at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:693)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/CrashlyticsCore: at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:690)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/CrashlyticsCore: at dalvik.system.NativeStart.main(Native Method)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: FATAL EXCEPTION: main
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{cinamaker.nlt.com.cinamaker/cinamaker.nlt.com.cinamaker.activity.MainActivity}: android.view.InflateException: Binary XML file line #111: Error inflating class cinamaker.nlt.com.cinamaker.widget.HorizontalListView.HorizontalListView
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2342)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2417)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.app.ActivityThread.access0(ActivityThread.java:148)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1355)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:99)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.os.Looper.loop(Looper.java:150)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5390)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at java.lang.reflect.Method.invokeNative(Native Method)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:525)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at dalvik.system.NativeStart.main(Native Method)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: Caused by: android.view.InflateException: Binary XML file line #111: Error inflating class cinamaker.nlt.com.cinamaker.widget.HorizontalListView.HorizontalListView
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.view.LayoutInflater.createView(LayoutInflater.java:620)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:268)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.app.Activity.setContentView(Activity.java:1968)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at cinamaker.nlt.com.cinamaker.activity.MainActivity.onCreate(MainActivity.java:65)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.app.Activity.performCreate(Activity.java:5303)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2296)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2417)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.app.ActivityThread.access0(ActivityThread.java:148)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1355)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:99)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.os.Looper.loop(Looper.java:150)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5390)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at java.lang.reflect.Method.invokeNative(Native Method)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:525)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at dalvik.system.NativeStart.main(Native Method)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: Caused by: java.lang.reflect.InvocationTargetException
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at java.lang.reflect.Constructor.constructNative(Native Method)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.view.LayoutInflater.createView(LayoutInflater.java:594)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:268)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.app.Activity.setContentView(Activity.java:1968)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at cinamaker.nlt.com.cinamaker.activity.MainActivity.onCreate(MainActivity.java:65)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.app.Activity.performCreate(Activity.java:5303)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2296)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2417)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.app.ActivityThread.access0(ActivityThread.java:148)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1355)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:99)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.os.Looper.loop(Looper.java:150)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5390)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at java.lang.reflect.Method.invokeNative(Native Method)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:525)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at dalvik.system.NativeStart.main(Native Method)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: Caused by: java.lang.NoClassDefFoundError: cinamaker.nlt.com.cinamaker.widget.HorizontalListView.HorizontalListView
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at cinamaker.nlt.com.cinamaker.widget.HorizontalListView.HorizontalListView.(HorizontalListView.java:365)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at java.lang.reflect.Constructor.constructNative(Native Method)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.view.LayoutInflater.createView(LayoutInflater.java:594)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:268)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.app.Activity.setContentView(Activity.java:1968)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at cinamaker.nlt.com.cinamaker.activity.MainActivity.onCreate(MainActivity.java:65)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.app.Activity.performCreate(Activity.java:5303)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2296)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2417)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.app.ActivityThread.access0(ActivityThread.java:148)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1355)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:99)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.os.Looper.loop(Looper.java:150)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5390)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at java.lang.reflect.Method.invokeNative(Native Method)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:525)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at dalvik.system.NativeStart.main(Native Method)
代码:
我不想在这里添加整个 class,它太大了。我只添加当前活跃的问题。
public class HorizonatlListView {
...
private DataSetObserver mAdapterDataObserver = new DataSetObserver() {
@Override
public void onChanged() {
mDataChanged = true;
// Clear so we can notify again as we run out of data
mHasNotifiedRunningLowOnData = false;
unpressTouchedChild();
// Invalidate and request layout to force this view to completely redraw itself
invalidate();
requestLayout();
}
@Override
public void onInvalidated() {
// Clear so we can notify again as we run out of data
mHasNotifiedRunningLowOnData = false;
unpressTouchedChild();
reset();
// Invalidate and request layout to force this view to completely redraw itself
invalidate();
requestLayout();
}
};
...
}
API 21+ 不会发生这种情况,因为只有 Dalvik 才需要多索引。 ART 没有 65536 个方法限制。所以,这是因为您的 类 从主 dex 文件中消失了。
也许它会对你有用:
1) http://blog.osom.info/2014/10/generating-main-dex-list-file.html
2)MultiDex NoClassDefFound error
我在我的应用程序中的嵌套静态和匿名 classes 上遇到了 NoClassDefFoundError。关键是,这种情况并非发生在我测试过的每台设备上。我已经阅读了很多 Whosebug 和 google 试图解决这个问题,但我仍然不明白为什么它会在 Zenphone 5 和 Galaxy Tab E (android 4.4.4) 上发生但在 nexus 7/ 上从未发生过10 或在具有 Android 5+.
的任何其他设备上我还尝试将所有嵌套的 classes 从基础 class 移到它们自己的 .java 文件中,这有帮助,但我想了解根本问题和修复它。
P.S。有可能,这个问题与 multidex 支持有关吗?
UPD 1
LogCat:
02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/CrashlyticsCore: Failed to execute task. 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/CrashlyticsCore: java.util.concurrent.TimeoutException 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/CrashlyticsCore: at java.util.concurrent.FutureTask.get(FutureTask.java:173) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/CrashlyticsCore: at com.crashlytics.android.core.CrashlyticsExecutorServiceWrapper.executeSyncLoggingException(CrashlyticsExecutorServiceWrapper.java:44) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/CrashlyticsCore: at com.crashlytics.android.core.CrashlyticsUncaughtExceptionHandler.uncaughtException(CrashlyticsUncaughtExceptionHandler.java:245) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/CrashlyticsCore: at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:693) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/CrashlyticsCore: at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:690) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/CrashlyticsCore: at dalvik.system.NativeStart.main(Native Method) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: FATAL EXCEPTION: main 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{cinamaker.nlt.com.cinamaker/cinamaker.nlt.com.cinamaker.activity.MainActivity}: android.view.InflateException: Binary XML file line #111: Error inflating class cinamaker.nlt.com.cinamaker.widget.HorizontalListView.HorizontalListView 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2342) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2417) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.app.ActivityThread.access0(ActivityThread.java:148) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1355) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:99) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.os.Looper.loop(Looper.java:150) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5390) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at java.lang.reflect.Method.invokeNative(Native Method) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:525) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at dalvik.system.NativeStart.main(Native Method) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: Caused by: android.view.InflateException: Binary XML file line #111: Error inflating class cinamaker.nlt.com.cinamaker.widget.HorizontalListView.HorizontalListView 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.view.LayoutInflater.createView(LayoutInflater.java:620) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.view.LayoutInflater.rInflate(LayoutInflater.java:755) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.view.LayoutInflater.rInflate(LayoutInflater.java:758) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:492) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:397) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:353) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:268) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.app.Activity.setContentView(Activity.java:1968) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at cinamaker.nlt.com.cinamaker.activity.MainActivity.onCreate(MainActivity.java:65) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.app.Activity.performCreate(Activity.java:5303) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2296) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2417) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.app.ActivityThread.access0(ActivityThread.java:148) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1355) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:99) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.os.Looper.loop(Looper.java:150) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5390) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at java.lang.reflect.Method.invokeNative(Native Method) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:525) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at dalvik.system.NativeStart.main(Native Method) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: Caused by: java.lang.reflect.InvocationTargetException 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at java.lang.reflect.Constructor.constructNative(Native Method) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at java.lang.reflect.Constructor.newInstance(Constructor.java:417) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.view.LayoutInflater.createView(LayoutInflater.java:594) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.view.LayoutInflater.rInflate(LayoutInflater.java:755) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.view.LayoutInflater.rInflate(LayoutInflater.java:758) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:492) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:397) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:353) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:268) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.app.Activity.setContentView(Activity.java:1968) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at cinamaker.nlt.com.cinamaker.activity.MainActivity.onCreate(MainActivity.java:65) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.app.Activity.performCreate(Activity.java:5303) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2296) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2417) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.app.ActivityThread.access0(ActivityThread.java:148) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1355) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:99) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.os.Looper.loop(Looper.java:150) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5390) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at java.lang.reflect.Method.invokeNative(Native Method) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:525) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at dalvik.system.NativeStart.main(Native Method) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: Caused by: java.lang.NoClassDefFoundError: cinamaker.nlt.com.cinamaker.widget.HorizontalListView.HorizontalListView 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at cinamaker.nlt.com.cinamaker.widget.HorizontalListView.HorizontalListView.(HorizontalListView.java:365) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at java.lang.reflect.Constructor.constructNative(Native Method) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at java.lang.reflect.Constructor.newInstance(Constructor.java:417) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.view.LayoutInflater.createView(LayoutInflater.java:594) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.view.LayoutInflater.rInflate(LayoutInflater.java:755) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.view.LayoutInflater.rInflate(LayoutInflater.java:758) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:492) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:397) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:353) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:268) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.app.Activity.setContentView(Activity.java:1968) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at cinamaker.nlt.com.cinamaker.activity.MainActivity.onCreate(MainActivity.java:65) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.app.Activity.performCreate(Activity.java:5303) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2296) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2417) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.app.ActivityThread.access0(ActivityThread.java:148) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1355) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:99) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.os.Looper.loop(Looper.java:150) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5390) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at java.lang.reflect.Method.invokeNative(Native Method) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:525) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 02-29 17:09:43.306 28749-28749/cinamaker.nlt.com.cinamaker E/AndroidRuntime: at dalvik.system.NativeStart.main(Native Method)
代码: 我不想在这里添加整个 class,它太大了。我只添加当前活跃的问题。
public class HorizonatlListView {
...
private DataSetObserver mAdapterDataObserver = new DataSetObserver() {
@Override
public void onChanged() {
mDataChanged = true;
// Clear so we can notify again as we run out of data
mHasNotifiedRunningLowOnData = false;
unpressTouchedChild();
// Invalidate and request layout to force this view to completely redraw itself
invalidate();
requestLayout();
}
@Override
public void onInvalidated() {
// Clear so we can notify again as we run out of data
mHasNotifiedRunningLowOnData = false;
unpressTouchedChild();
reset();
// Invalidate and request layout to force this view to completely redraw itself
invalidate();
requestLayout();
}
};
...
}
API 21+ 不会发生这种情况,因为只有 Dalvik 才需要多索引。 ART 没有 65536 个方法限制。所以,这是因为您的 类 从主 dex 文件中消失了。 也许它会对你有用: 1) http://blog.osom.info/2014/10/generating-main-dex-list-file.html 2)MultiDex NoClassDefFound error