简体   繁体   English

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

[英]Why the app is crashing when I trying to go to home activity

Mu app crashes when I try to navigate to home activity by clicking a button.当我尝试通过单击按钮导航到家庭活动时,Mu 应用程序崩溃。 It was working fine earlier.早些时候它工作正常。 I'm trying to build the project after a long time, now I'm getting this error.很长一段时间后,我试图构建该项目,现在出现此错误。 Here is the 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)

Maybe its because you might have had a recent Android studio upgrade.也许是因为您最近升级了 Android Studio。

Try the following way :尝试以下方式:

Reason of this exception is AppcompatActivity derived from the v7 library.此异常的原因是从 v7 库派生的 AppcompatActivity。 so we should provide proper library based on your gradle and SDK.所以我们应该根据你的 gradle 和 SDK 提供合适的库。

should update the dependency Libraries also.也应该更新依赖库。 Right click on the project in the project structure -> select Open module settings and select dependencies tab -> Library module-> then type which library you want add to the project.右键单击项目结构中的项目-> 选择打开模块设置并选择依赖项选项卡-> 库模块-> 然后键入要添加到项目中的库。 It shows the latest libraries based on your gradle updated version, then select latest one and remove the existing one.它根据您的 gradle 更新版本显示最新的库,然后选择最新的库并删除现有的库。 For example In my project "appcompat-v7" version is 23.4.0 then I changed it to 24.2.0.例如在我的项目“appcompat-v7”版本是 23.4.0 然后我把它改成了 24.2.0。

You should always add the latest version of libraries to your app build.gradle您应该始终将最新版本的库添加到您的应用 build.gradle

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM