AppCompatActivity is not working properly

拟墨画扇 提交于 2019-12-24 09:34:56

问题


I am developing an app which uses AppCompatActivity. I have been struggling since so many days solving this error but no luck and no reply for such an answer on StackOverflow. The gradle is built successfully without any error. But when the app is installed in the device, I get a force close error.

I am attaching my Android Monitor(logcat) content here. Please help me with this.

java.lang.NoSuchMethodError:
android.support.v4.view.ViewCompat.setOnApplyWindowInsetsListener(Landroid/view/View;Landroid/support/v4/view/OnApplyWindowInsetsListener;)V
at
android.support.design.internal.ScrimInsetsFrameLayout.<init>(ScrimInsetsFrameLayout.java:61)
at
android.support.design.widget.NavigationView.<init>(NavigationView.java:99)
at
android.support.design.widget.NavigationView.<init>(NavigationView.java:95)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)   at
 sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
 at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at
org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:465)
at
org.jetbrains.android.uipreview.ViewLoader.loadClass(ViewLoader.java:172)
at
org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:105)
at
com.android.tools.idea.rendering.LayoutlibCallbackImpl.loadView(LayoutlibCallbackImpl.java:186)
at
android.view.BridgeInflater.loadCustomView(BridgeInflater.java:334)
at
android.view.BridgeInflater.loadCustomView(BridgeInflater.java:345)
at
android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:245)
at
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
at
android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:858)
at
 android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:834)  at
android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
 at android.view.LayoutInflater.inflate(LayoutInflater.java:518)

here is my gradle file attached. Please have a look at it.


回答1:


The answer to my question was given by @Piyush. The two dependencies were clashing I guess. so in short the answer to my issue will be if you are using

 compile 'com.android.support:appcompat-v7:24.+'

etc.

then DO NOT USE

compile 'com.google.android:support-v4:r7'

along with it.




回答2:


Change your app compat gradle as like below

compile 'com.android.support:appcompat-v7:23.4.0'

don't use gradle with +

compile 'com.android.support:appcompat-v7:23.+'

Hope this helps..!!



来源:https://stackoverflow.com/questions/39631655/appcompatactivity-is-not-working-properly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!