I am making an app which supports from API 16 to API 22. I am using RecyclerView to display item list. My code for the layout is as follows
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="56dp"
android:layout_gravity="center_vertical"
android:background="@drawable/ripple"
android:clickable="true"
android:orientation="horizontal"
android:paddingLeft="@dimen/default_padding"
android:paddingRight="@dimen/default_padding">
<ImageView
android:id="@+id/s_icon"
android:layout_width="@dimen/drawer_icon_size"
android:layout_height="@dimen/drawer_icon_size"
android:layout_gravity="center_vertical"
android:src="@drawable/ic_sd"
android:tint="@color/storage_image_tint" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/drawer_item_label_margin"
android:layout_marginStart="@dimen/drawer_item_label_margin"
android:orientation="vertical">
<TextView
android:id="@+id/s_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world"
android:textColor="@color/storage_label_selector" />
<TextView
android:id="@+id/s_stat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:text="@string/hello_blank_fragment"
android:textColor="@color/storage_stat_selector"
android:textSize="@dimen/storage_stat_text" />
<ProgressBar
android:id="@+id/s_progress"
style="@style/CustomProgressBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/storage"
android:progressDrawable="@drawable/storage" />
</LinearLayout>
</LinearLayout>
This code works fine in API 21 and 22 but when I launch my app in API 16 (JellyBean), My logcat shows the following error.
07-27 05:58:42.115 11590-11596/? E/jdwp﹕ Failed sending reply to debugger: Broken pipe
07-27 05:58:42.487 11590-11590/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
android.view.InflateException: Binary XML file line #12: Error inflating class <unknown>
at android.view.LayoutInflater.createView(LayoutInflater.java:613)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
at com.zaeron.filexplorer.Adapter$Storage.onCreateViewHolder(Adapter.java:84)
at com.zaeron.filexplorer.Adapter$Storage.onCreateViewHolder(Adapter.java:30)
at android.support.v7.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:5062)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4368)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4278)
at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:1947)
at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1359)
at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1322)
at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:556)
at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:2673)
at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:2971)
at android.view.View.layout(View.java:13754)
at android.view.ViewGroup.layout(ViewGroup.java:4362)
at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
at android.view.View.layout(View.java:13754)
at android.view.ViewGroup.layout(ViewGroup.java:4362)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1649)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1507)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1420)
at android.view.View.layout(View.java:13754)
at android.view.ViewGroup.layout(ViewGroup.java:4362)
at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
at android.widget.ScrollView.onLayout(ScrollView.java:1438)
at android.view.View.layout(View.java:13754)
at android.view.ViewGroup.layout(ViewGroup.java:4362)
at android.support.v4.widget.DrawerLayout.onLayout(DrawerLayout.java:931)
at android.view.View.layout(View.java:13754)
at android.view.ViewGroup.layout(ViewGroup.java:4362)
at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
at android.view.View.layout(View.java:13754)
at android.view.ViewGroup.layout(ViewGroup.java:4362)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1649)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1507)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1420)
at android.view.View.layout(View.java:13754)
at android.view.ViewGroup.layout(ViewGroup.java:4362)
at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
at android.view.View.layout(View.java:13754)
at android.view.ViewGroup.layout(ViewGroup.java:4362)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1649)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1507)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1420)
at android.view.View.layout(View.java:13754)
at android.view.ViewGroup.layout(ViewGroup.java:4362)
at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
at android.view.View.layout(View.java:13754)
at android.view.ViewGroup.layout(ViewGroup.java:4362)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1866)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1687)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:998)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4212)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
at android.view.Choreographer.doCallba
I am trying to figure this out but I'm not getting how to solve this. BTW I'm new to Android.
EDIT: My Code for RecyclerView
<FrameLayout
android:layout_marginTop="8dp"
android:id="@+id/sRecyclerViewContainer"
style="@style/StorageRecyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.RecyclerView
android:id="@+id/sRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:overScrollMode="never" />
</FrameLayout>
EDIT: I found the problem in my code. Actually nothing is wrong in recyclerView but this recyclerView displays all storages in the device. But when I run it on jellybean most probably there is a problem fetching internal storage of the device. So can anybody help me how do I find internal storage in JellyBean
I use Environment. getExternalStorageDirectory()
to get storage directory