错误膨胀类xxx.RecyclerView,xxx.InvocationTargetException,NoSuchMethodError:无虚方法getScaledHorizo​​ntalScrollFactor()F

时间:2018-06-04 06:59:36

标签: android-recyclerview

在某些设备上,我的应用会收到以下错误日志,但我真的不知道为什么会出现这个错误。 这些是收集到在线用户的崩溃日志。我自己的同一设备不能重现这个错误。

uncaught exception at Thu May 31 19:17:57 GMT+08:00 2018\n android.view.InflateException: Binary XML file line #6: Binary XML file line #6: Error inflating class android.support.v7.widget.RecyclerView\n
\tat android.view.LayoutInflater.inflate(LayoutInflater.java:539)\n
\tat android.view.LayoutInflater.inflate(LayoutInflater.java:423)\n
\tat com.sogou.map.android.sogounav.history.HistoryListView.initView(HistoryListView.java:88)\n
\tat com.sogou.map.android.sogounav.history.HistoryListView.<init>(HistoryListView.java:83)\n
\tat com.sogou.map.android.sogounav.search.SearchIntermiPageView.<init>(SearchIntermiPageView.java:106)\n
\tat com.sogou.map.android.sogounav.search.e.a(SearchIntermiPage.java:92)\n
\tat com.sogou.map.mobile.app.b.a(PageManager.java:731)\n
\tat com.sogou.map.mobile.app.b.c(PageManager.java:1175)\n
\tat com.sogou.map.mobile.app.b$4.run(PageManager.java:1079)\n
\tat com.sogou.map.mobile.app.b.g(PageManager.java:1322)\n
\tat com.sogou.map.mobile.app.b$1.run(PageManager.java:423)\n
\tat android.os.Handler.handleCallback(Handler.java:739)\n
\tat android.os.Handler.dispatchMessage(Handler.java:95)\n
\tat android.os.Looper.loop(Looper.java:148)\n
\tat android.app.ActivityThread.main(ActivityThread.java:5417)\n
\tat java.lang.reflect.Method.invoke(Native Method)\n
\tat com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)\n
\tat com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)\n
Caused by: android.view.InflateException: Binary XML file line #6: Error inflating class android.support.v7.widget.RecyclerView\n
\tat android.view.LayoutInflater.createView(LayoutInflater.java:645)\n
\tat android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764)\n
\tat android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)\n
\tat android.view.LayoutInflater.rInflate(LayoutInflater.java:835)\n
\tat android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)\n
\tat android.view.LayoutInflater.inflate(LayoutInflater.java:515)\n
\tat android.view.LayoutInflater.inflate(LayoutInflater.java:423)\n
\tat com.sogou.map.android.sogounav.history.HistoryListView.initView(HistoryListView.java:88)\n
\tat com.sogou.map.android.sogounav.history.HistoryListView.<init>(HistoryListView.java:83)\n
\tat com.sogou.map.android.sogounav.search.SearchIntermiPageView.<init>(SearchIntermiPageView.java:106)\n
\tat com.sogou.map.android.sogounav.search.e.a(SearchIntermiPage.java:92)\n
\tat com.sogou.map.mobile.app.b.a(PageManager.java:731)\n
\tat com.sogou.map.mobile.app.b.c(PageManager.java:1175)\n
\tat com.sogou.map.mobile.app.b$4.run(PageManager.java:1079)\n
\tat com.sogou.map.mobile.app.b.g(PageManager.java:1322)\n
\tat com.sogou.map.mobile.app.b$1.run(PageManager.java:423)\n
\tat android.os.Handler.handleCallback(Handler.java:739)\n
\tat android.os.Handler.dispatchMessage(Handler.java:95)\n
\tat android.os.Looper.loop(Looper.java:148)\n
\tat android.app.ActivityThread.main(ActivityThread.java:5417)\n
\tat java.lang.reflect.Method.invoke(Native Method)\n
\tat com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)\n
\tat com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)\n
Caused by: java.lang.reflect.InvocationTargetException\n
\tat java.lang.reflect.Constructor.newInstance(Native Method)\n
\tat android.view.LayoutInflater.createView(LayoutInflater.java:619)\n
\tat android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764)\n
\tat android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)\n
\tat android.view.LayoutInflater.rInflate(LayoutInflater.java:835)\n
\tat android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)\n
\tat android.view.LayoutInflater.inflate(LayoutInflater.java:515)\n
\tat android.view.LayoutInflater.inflate(LayoutInflater.java:423)\n
\tat com.sogou.map.android.sogounav.history.HistoryListView.initView(HistoryListView.java:88)\n
\tat com.sogou.map.android.sogounav.history.HistoryListView.<init>(HistoryListView.java:83)\n
\tat com.sogou.map.android.sogounav.search.SearchIntermiPageView.<init>(SearchIntermiPageView.java:106)\n
\tat com.sogou.map.android.sogounav.search.e.a(SearchIntermiPage.java:92)\n
\tat com.sogou.map.mobile.app.b.a(PageManager.java:731)\n\tat com.sogou.map.mobile.app.b.c(PageManager.java:1175)\n
\tat com.sogou.map.mobile.app.b$4.run(PageManager.java:1079)\n\tat com.sogou.map.mobile.app.b.g(PageManager.java:1322)\n
\tat com.sogou.map.mobile.app.b$1.run(PageManager.java:423)\n\tat android.os.Handler.handleCallback(Handler.java:739)\n
\tat android.os.Handler.dispatchMessage(Handler.java:95)\n\tat android.os.Looper.loop(Looper.java:148)\n
\tat android.app.ActivityThread.main(ActivityThread.java:5417)\n\tat java.lang.reflect.Method.invoke(Native Method)\n
\tat com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)\n
\tat com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)\n
Caused by: java.lang.NoSuchMethodError: No virtual method getScaledHorizontalScrollFactor()F in class Landroid/view/ViewConfiguration; or its super classes (declaration of 'android.view.ViewConfiguration' appears in /system/framework/framework.jar:classes2.dex)\n
\tat android.support.v4.view.ViewConfigurationCompat.getScaledHorizontalScrollFactor(ViewConfigurationCompat.java:83)\n
\tat android.support.v7.widget.RecyclerView.<init>(RecyclerView.java:584)\n
\tat android.support.v7.widget.RecyclerView.<init>(RecyclerView.java:566)\n
\tat java.lang.reflect.Constructor.newInstance(Native Method)\n
\tat android.view.LayoutInflater.createView(LayoutInflater.java:619)\n
\tat android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764)\n
\tat android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)\n
\tat android.view.LayoutInflater.rInflate(LayoutInflater.java:835)\n
\tat android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)\n
\tat android.view.LayoutInflater.inflate(LayoutInflater.java:515)\n
\tat android.view.LayoutInflater.inflate(LayoutInflater.java:423)\n
\tat com.sogou.map.android.sogounav.history.HistoryListView.initView(HistoryListView.java:88)\n
\tat com.sogou.map.android.sogounav.history.HistoryListView.<init>(HistoryListView.java:83)\n
\tat com.sogou.map.android.sogounav.search.SearchIntermiPageView.<init>(SearchIntermiPageView.java:106)\n
\tat com.sogou.map.android.sogounav.search.e.a(SearchIntermiPage.java:92)\n
\tat com.sogou.map.mobile.app.b.a(PageManager.java:731)\n
\tat com.sogou.map.mobile.app.b.c(PageManager.java:1175)\n
\tat com.sogou.map.mobile.app.b$4.run(PageManager.java:1079)\n
\tat com.sogou.map.mobile.app.b.g(PageManager.java:1322)\n
\tat com.sogou.map.mobile.app.b$1.run(PageManager.java:423)\n
\tat android.os.Handler.handleCallback(Handler.java:739)\n
\tat android.os.Handler.dispatchMessage(Handler.java:95)\n
\tat android.os.Looper.loop(Looper.java:148)\n\tat android.app.ActivityThread.main(ActivityThread.java:5417)\n
\tat java.lang.reflect.Method.invoke(Native Method)\n
\tat com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)\n
\tat com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)\n",
  

这是崩溃的代码,发生在initView-&gt; inflate

代码类HistoryListView.java:

public class HistoryListView extends FrameLayout {

	private HistoryAdapter navHistoryAdapter;
	private View topView;

	private Context mContext;

	public HistoryListView(Context context) {
		super(context);
		mContext = context;
		initView();
	}

	private void initView() {
		topView = LayoutInflater.from(mContext).inflate(R.layout.sogounav_history, this, true);
		RecyclerView historyRecyclerView = (RecyclerView) topView.findViewById(R.id.sogounav_nav_history_recycler_view);
		historyRecyclerView.setLayoutManager(new HistoryLayoutManager(mContext));
		historyRecyclerView.addItemDecoration(new SpaceItemDecoration(0, 0, 0, ViewUtils.getPixel(SysUtils.getApp(), 1)));
		navHistoryAdapter = new HistoryAdapter(mOnItemClickListener);
		historyRecyclerView.setNestedScrollingEnabled(false);
		historyRecyclerView.setAdapter(navHistoryAdapter);

		... ...
		... ...
		... ...
	}

	... ...
	... ...
	... ...

}

以下是对RecyclerView的引用 代码sogounav_history.xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.v7.widget.RecyclerView
        android:id="@+id/sogounav_nav_history_recycler_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center" />

</RelativeLayout>

0 个答案:

没有答案