简体   繁体   中英

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. 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.

Try the following way :

Reason of this exception is AppcompatActivity derived from the v7 library. so we should provide proper library based on your gradle and 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. For example In my project "appcompat-v7" version is 23.4.0 then I changed it to 24.2.0.

You should always add the latest version of libraries to your app build.gradle

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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