当我尝试去家庭活动时为什么应用程序崩溃了

时间:2017-02-05 03:29:57

标签: java android android-intent

当我尝试通过单击按钮导航到主页活动时,Mu应用程序崩溃了。它早先工作得很好。我想在很长一段时间后建立这个项目,现在我收到了这个错误。这是堆栈跟踪:  Stacktrace

02-05 07:22:53.134 20645-20645/com.fault.reporter D/InputTransport: Input channel constructed: fd=70 02-05 07:22:53.134 20645-20645/com.fault.reporter D/ViewRootImpl@83d1b0a[HomeActivity]: setView = DecorView@3fdbf7b[HomeActivity] touchMode=true 02-05 07:22:53.137 20645-20645/com.fault.reporter D/AndroidRuntime: Shutting down VM 02-05 07:22:53.137 20645-20645/com.fault.reporter E/AndroidRuntime: FATAL EXCEPTION: main
                                                                    Process: com.fault.reporter, PID: 20645
                                                                    java.lang.NoSuchMethodError: No static method getDisplay(Landroid/view/View;)Landroid/view/Display; in class Landroid/support/v4/view/ViewCompat; or its super classes (declaration of 'android.support.v4.view.ViewCompat' appears in /data/data/com.fault.reporter/files/instant-run/dex/slice-com.android.support-support-v4-23.1.1_06456312a9f4ec02807847836689deefb3552449-classes.dex)
                                                                        at android.support.v7.widget.RecyclerView.onAttachedToWindow(RecyclerView.java:2457)
                                                                        at android.view.View.dispatchAttachedToWindow(View.java:16633)
                                                                        at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3149)
                                                                        at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3156)
                                                                        at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3156)
                                                                        at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3156)
                                                                        at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3156)
                                                                        at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3156)
                                                                        at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3156)
                                                                        at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3156)
                                                                        at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1768)
                                                                        at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1490)
                                                                        at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7027)
                                                                        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:927)
                                                                        at android.view.Choreographer.doCallbacks(Choreographer.java:702)
                                                                        at android.view.Choreographer.doFrame(Choreographer.java:638)
                                                                        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:913)
                                                                        at android.os.Handler.handleCallback(Handler.java:751)
                                                                        at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                        at android.os.Looper.loop(Looper.java:154)
                                                                        at android.app.ActivityThread.main(ActivityThread.java:6688)
                                                                        at java.lang.reflect.Method.invoke(Native Method)
                                                                        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
                                                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)

2 个答案:

答案 0 :(得分:2)

也许是因为你可能有最近的Android工作室升级。

尝试以下方式:

此异常的原因是从v7库派生的AppcompatActivity。所以我们应该根据你的gradle和SDK提供合适的库。

也应该更新依赖库。 右键单击项目结构中的项目 - >选择打开模块设置并选择依赖项选项卡 - >库模块 - >然后键入要添加到项目的库。它会根据您的gradle更新版本显示最新的库,然后选择最新的库并删除现有的库。 例如在我的项目" appcompat-v7"版本是23.4.0然后我将其更改为24.2.0。

您应该始终将最新版本的库添加到您的app build.gradle

答案 1 :(得分:0)

转到您的gradle.build文件,并确保所有依赖项都是最新的(新版本)。