Reusing AndroidTV RowsFragment outside BrowseFragment - android

I'm trying to reuse the RowsFragment provided by AndroidTV Leanback outside of a BrowseFragment, to have a similar row interaction look & feel on a different layout, but I'm getting XML-inflation errors that I haven't been able to debug and solve.
The implementation itself is similar to what is implemented here: https://medium.com/building-for-android-tv , but in the blog he's replacing different fragments of the same kind inside a BrowseFragment. Is there something fundamentally wrong with my approach? If so, why? I've been reading through the Leanback sources and haven't been able to find anything that I would understand (although it's a large library) that would couple the fragments to that degree.
A reproduction of the relevant code:
https://gist.github.com/orbitbot/c9070ed00961c3abe4ca
02-26 12:12:26.950 4465-4527/com.my.client E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.my.client, PID: 4465
android.view.InflateException: Binary XML file line #18: Error inflating class <unknown>
at android.view.LayoutInflater.createView(LayoutInflater.java:620)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.inflate(LayoutInflater.java:462)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at android.support.v17.leanback.widget.RowContainerView.<init>(RowContainerView.java:48)
at android.support.v17.leanback.widget.RowContainerView.<init>(RowContainerView.java:37)
at android.support.v17.leanback.widget.RowPresenter.onCreateViewHolder(RowPresenter.java:169)
at android.support.v17.leanback.widget.ItemBridgeAdapter.onCreateViewHolder(ItemBridgeAdapter.java:247)
at android.support.v7.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:4121)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:3431)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:3340)
at android.support.v17.leanback.widget.GridLayoutManager.getViewForPosition(GridLayoutManager.java:573)
at android.support.v17.leanback.widget.GridLayoutManager$2.createItem(GridLayoutManager.java:1057)
at android.support.v17.leanback.widget.StaggeredGrid.appendItemToRow(StaggeredGrid.java:242)
at android.support.v17.leanback.widget.StaggeredGridDefault.appendItems(StaggeredGridDefault.java:49)
at android.support.v17.leanback.widget.GridLayoutManager.appendOneVisibleItem(GridLayoutManager.java:1263)
at android.support.v17.leanback.widget.GridLayoutManager.appendVisibleItems(GridLayoutManager.java:1273)
at android.support.v17.leanback.widget.GridLayoutManager.onLayoutChildren(GridLayoutManager.java:1554)
at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:1988)
at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:2237)
at android.view.View.layout(View.java:14817)
at android.view.ViewGroup.layout(ViewGroup.java:4631)
at android.support.v17.leanback.widget.ScaleFrameLayout.onLayout(ScaleFrameLayout.java:135)
at android.view.View.layout(View.java:14817)
at android.view.ViewGroup.layout(ViewGroup.java:4631)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
at android.view.View.layout(View.java:14817)
at android.view.ViewGroup.layout(ViewGroup.java:4631)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
at android.view.View.layout(View.java:14817)
at android.view.ViewGroup.layout(ViewGroup.java:4631)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
at android.view.View.layout(View.java:14817)
at android.view.ViewGroup.layout(ViewGroup.java:4631)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
at android.view.View.layout(View.java:14817)
at android.view.ViewGroup.layout(ViewGroup.java:4631)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
at android.view.View.layout(View.java:14817)
at android.view.ViewGroup.layout(ViewGroup.java:4631)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1989)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1746)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1000)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5672)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:772

Make sure that your ChangePicActivity has proper theme in AndroidManifest.xml
Add android:theme="#style/Theme.Leanback" to relevant activity tag.
Like this
<activity
android:name=".ChangePicActivity"
android:theme="#style/Theme.Leanback"
>
[...]

Related

RecyclerView Error when remove last item in list

I have problem with my recyclerview. I have function that remove item in list.
When last item didn't showing, it had work fine. But when last item did showing in the end of screen (list), i got error after excute remove item from list.
This my logcat:
java.lang.IllegalArgumentException: Scrapped or attached views may not be recycled. isScrap:false isAttached:true
at android.support.v7.widget.RecyclerView$Recycler.recycleViewHolderInternal(RecyclerView.java:5778)
at android.support.v7.widget.RecyclerView$Recycler.quickRecycleScrapView(RecyclerView.java:5885)
at android.support.v7.widget.RecyclerView$LayoutManager.removeAndRecycleScrapInt(RecyclerView.java:8547)
at android.support.v7.widget.RecyclerView.dispatchLayoutStep3(RecyclerView.java:3698)
at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3365)
at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3886)
at android.view.View.layout(View.java:15664)
at android.view.ViewGroup.layout(ViewGroup.java:4869)
at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1055)
at android.view.View.layout(View.java:15664)
at android.view.ViewGroup.layout(ViewGroup.java:4869)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
at android.view.View.layout(View.java:15664)
at android.view.ViewGroup.layout(ViewGroup.java:4869)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1677)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1531)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1440)
at android.view.View.layout(View.java:15664)
at android.view.ViewGroup.layout(ViewGroup.java:4869)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
at android.view.View.layout(View.java:15664)
at android.view.ViewGroup.layout(ViewGroup.java:4869)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1677)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1531)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1440)
at android.view.View.layout(View.java:15664)
at android.view.ViewGroup.layout(ViewGroup.java:4869)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
at android.view.View.layout(View.java:15664)
at android.view.ViewGroup.layout(ViewGroup.java:4869)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2246)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1968)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1200)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6401)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:803)
at android.view.Choreographer.doCallbacks(Choreographer.java:603)
at android.view.Choreographer.doFrame(Choreographer.java:573)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:789)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5335)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
at dalvik.system.NativeStart.main(Native Method)
I remove item like this:
public void delete(Entity entity) {
entities.remove(entity);
notifyDataSetChanged();
}
What's wrong here? Have any suggestion for my problem? Thanks!
I think may be the cause of this error is remove item i called from Dispoable of rx thread? When i remove item in my activity it's work fine.
You can use notifyItemRangeChanged or notifyItemChanged method RecyclerView Adapter.

Crashlytics reporting multiples issues for TextView.makeSingleLayout

I am receiving multiples crash reports about the same error, but I have no idea what is may causing it.
The exception that is throwing is ArrayIndexOutOfBoundsException in android.widget.TextView.makeSingleLayout.
I know it is not about Android versions and devices types, since it is getting reports from multiple versions and devices.
Here is what I am getting from Crashlytics:
Fatal Exception: java.lang.ArrayIndexOutOfBoundsException: length=125; index=-1
at android.text.StaticLayout.calculateEllipsis(StaticLayout.java:785)
at android.text.StaticLayout.out(StaticLayout.java:704)
at android.text.StaticLayout.generate(StaticLayout.java:410)
at android.text.StaticLayout.<init>(StaticLayout.java:140)
at android.widget.TextView.makeSingleLayout(TextView.java:6199)
at android.widget.TextView.makeNewLayout(TextView.java:6056)
at android.widget.TextView.onMeasure(TextView.java:6432)
at android.view.View.measure(View.java:16653)
at android.widget.LinearLayout.measureHorizontal(LinearLayout.java:1231)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:590)
at android.view.View.measure(View.java:16653)
at android.widget.ListView.setupChild(ListView.java:1870)
at android.widget.ListView.makeAndAddView(ListView.java:1793)
at android.widget.ListView.fillDown(ListView.java:691)
at android.widget.ListView.fillFromTop(ListView.java:752)
at android.widget.ListView.layoutChildren(ListView.java:1616)
at android.widget.AbsListView.onLayout(AbsListView.java:2087)
at android.view.View.layout(View.java:14973)
at android.view.ViewGroup.layout(ViewGroup.java:4637)
at android.support.v4.widget.SwipeRefreshLayout.onLayout(SwipeRefreshLayout.java:636)
at android.view.View.layout(View.java:14973)
at android.view.ViewGroup.layout(ViewGroup.java:4637)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
at android.view.View.layout(View.java:14973)
at android.view.ViewGroup.layout(ViewGroup.java:4637)
at android.support.design.widget.CoordinatorLayout.layoutChild(CoordinatorLayout.java:1167)
at android.support.design.widget.CoordinatorLayout.onLayoutChild(CoordinatorLayout.java:852)
at android.support.design.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java:871)
at android.view.View.layout(View.java:14973)
at android.view.ViewGroup.layout(ViewGroup.java:4637)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
at android.view.View.layout(View.java:14973)
at android.view.ViewGroup.layout(ViewGroup.java:4637)
at android.support.v7.widget.ActionBarOverlayLayout.onLayout(ActionBarOverlayLayout.java:437)
at android.view.View.layout(View.java:14973)
at android.view.ViewGroup.layout(ViewGroup.java:4637)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
at android.view.View.layout(View.java:14973)
at android.view.ViewGroup.layout(ViewGroup.java:4637)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
at android.view.View.layout(View.java:14973)
at android.view.ViewGroup.layout(ViewGroup.java:4637)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
at android.view.View.layout(View.java:14973)
at android.view.ViewGroup.layout(ViewGroup.java:4637)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1995)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1752)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1008)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5717)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
at android.view.Choreographer.doCallbacks(Choreographer.java:574)
at android.view.Choreographer.doFrame(Choreographer.java:544)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5127)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:825)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:641)
at dalvik.system.NativeStart.main(NativeStart.java)
Is there any solution for that?
I do not write a explicit implementation for TextView.makeSingleLayout.
It has been almost a year, so my memory on this is a little fuzzy, but...
I faced what I suspect is the same problem in my own app. For me, it was happening because I was using android:ellipsize="start" without also using android:singleLine="true".
We had switched all of our android:singleLine="true" attributes to the recommended android:maxLines="1", but it turns out that there's a bug in how the system calculates the ellipsis that is triggered if singleLine isn't present.
So I believe you can solve this issue by simply adding android:singleLine="true" to your TextViews that are using ellipsize attrs.

java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0 and some time my appcrash and some time work properly [duplicate]

This question already has answers here:
What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it?
(26 answers)
Closed 5 years ago.
Error:
03-28 14:23:08.466 8743-8743/com.furbonics.furbonicsexecutive
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.furbonics.furbonicsexecutive, PID: 8743
java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0
at
java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255)
at java.util.ArrayList.get(ArrayList.java:308)
at android.widget.ArrayAdapter.getItem(ArrayAdapter.java:337)
at
android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:390)
at android.widget.ArrayAdapter.getView(ArrayAdapter.java:362)
at android.widget.Spinner.makeView(Spinner.java:592)
at android.widget.Spinner.layout(Spinner.java:540)
at android.widget.Spinner.onLayout(Spinner.java:502)
at android.view.View.layout(View.java:14845)
at android.view.ViewGroup.layout(ViewGroup.java:4631)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
at
android.widget.LinearLayout.layoutHorizontal(LinearLayout.java:1660)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1436)
at android.view.View.layout(View.java:14845)
at android.view.ViewGroup.layout(ViewGroup.java:4631)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
at android.view.View.layout(View.java:14845)
at android.view.ViewGroup.layout(ViewGroup.java:4631)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
at android.widget.ScrollView.onLayout(ScrollView.java:1468)
at android.view.View.layout(View.java:14845)
at android.view.ViewGroup.layout(ViewGroup.java:4631)
at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1055)
at android.view.View.layout(View.java:14845)
at android.view.ViewGroup.layout(ViewGroup.java:4631)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
at android.view.View.layout(View.java:14845)
at android.view.ViewGroup.layout(ViewGroup.java:4631)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
at android.view.View.layout(View.java:14845)
at android.view.ViewGroup.layout(ViewGroup.java:4631)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
at android.view.View.layout(View.java:14845)
at android.view.ViewGroup.layout(ViewGroup.java:4631)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
at android.view.View.layout(View.java:14845)
at android.view.ViewGroup.layout(ViewGroup.java:4631)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
at android.view.View.layout(View.java:14845)
at android.view.ViewGroup.layout(ViewGroup.java:4631)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
at android.view.View.layout(View.java:14845)
at android.view.ViewGroup.layout(ViewGroup.java:4631)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2026)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1783)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1039)
at
android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5648)
at
android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
at android.view.Choreographer.doCallbacks(Choreographer.java:574)
at android.view.Choreographer.doFrame(Choreographer.java:544)
at
android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
at android.os.Handler.handleCallback(Handler.java:733)
at android.o
You are trying to read a value from an empty array
lang.IndexOutOfBoundsException: Invalid index 0, size is 0.
Verify that the array is not empty before accessing a value in your code.
It means you are not able to fetch data. First use log and check if output is shown if no then check your code also surround your code for fetching with try and catch.

abstract method not implemented in RecyclerView Adapter

I added some feature to an existing running project and I tested the Application full testing after that to find out that any RecyclerView crashes after add/removing items from it ( after notifying the adapter with the changes ).
I am using notifyDataSetChanged() and I tried to use notifyItemRemoved() and notifyItemInserted() but the problem still happening.
My gradle file :
android {
compileSdkVersion 23
buildToolsVersion '23.0.3'
defaultConfig {
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.2.0'
compile 'com.android.support:cardview-v7:23.2.0'
compile 'com.android.support:recyclerview-v7:23.2.0'
compile 'com.android.support:design:23.2.0'
.......
.......
The Logs :
08-29 09:48:21.874: W/dalvikvm(4290): threadid=1: thread exiting with uncaught exception (group=0xb2d29b20)
08-29 09:48:21.874: W/System.err(4290): java.lang.AbstractMethodError: abstract method not implemented
08-29 09:48:21.884: W/System.err(4290): at android.support.v7.widget.RecyclerView$ItemAnimator.animateDisappearance(RecyclerView.java)
08-29 09:48:21.884: W/System.err(4290): at android.support.v7.widget.RecyclerView.animateDisappearance(RecyclerView.java:3252)
08-29 09:48:21.884: W/System.err(4290): at android.support.v7.widget.RecyclerView.access$700(RecyclerView.java:147)
08-29 09:48:21.884: W/System.err(4290): at android.support.v7.widget.RecyclerView$4.processDisappeared(RecyclerView.java:431)
08-29 09:48:21.884: W/System.err(4290): at android.support.v7.widget.ViewInfoStore.process(ViewInfoStore.java:246)
08-29 09:48:21.884: W/System.err(4290): at android.support.v7.widget.RecyclerView.dispatchLayoutStep3(RecyclerView.java:3098)
08-29 09:48:21.884: W/System.err(4290): at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:2917)
08-29 09:48:21.884: W/System.err(4290): at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3283)
08-29 09:48:21.884: W/System.err(4290): at android.view.View.layout(View.java:14817)
08-29 09:48:21.884: W/System.err(4290): at android.view.ViewGroup.layout(ViewGroup.java:4631)
08-29 09:48:21.884: W/System.err(4290): at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1055)
08-29 09:48:21.884: W/System.err(4290): at android.view.View.layout(View.java:14817)
08-29 09:48:21.884: W/System.err(4290): at android.view.ViewGroup.layout(ViewGroup.java:4631)
08-29 09:48:21.884: W/System.err(4290): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
08-29 09:48:21.884: W/System.err(4290): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525)
08-29 09:48:21.884: W/System.err(4290): at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
08-29 09:48:21.884: W/System.err(4290): at android.view.View.layout(View.java:14817)
08-29 09:48:21.884: W/System.err(4290): at android.view.ViewGroup.layout(ViewGroup.java:4631)
08-29 09:48:21.884: W/System.err(4290): at android.support.design.widget.HeaderScrollingViewBehavior.layoutChild(HeaderScrollingViewBehavior.java:122)
08-29 09:48:21.884: W/System.err(4290): at android.support.design.widget.ViewOffsetBehavior.onLayoutChild(ViewOffsetBehavior.java:42)
08-29 09:48:21.884: W/System.err(4290): at android.support.design.widget.AppBarLayout$ScrollingViewBehavior.onLayoutChild(AppBarLayout.java:1170)
08-29 09:48:21.894: W/System.err(4290): at android.support.design.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java:814)
08-29 09:48:21.894: W/System.err(4290): at android.view.View.layout(View.java:14817)
08-29 09:48:21.894: W/System.err(4290): at android.view.ViewGroup.layout(ViewGroup.java:4631)
08-29 09:48:21.894: W/System.err(4290): at android.support.v4.widget.DrawerLayout.onLayout(DrawerLayout.java:1191)
08-29 09:48:21.894: W/System.err(4290): at android.view.View.layout(View.java:14817)
08-29 09:48:21.894: W/System.err(4290): at android.view.ViewGroup.layout(ViewGroup.java:4631)
08-29 09:48:21.894: W/System.err(4290): at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
08-29 09:48:21.894: W/System.err(4290): at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
08-29 09:48:21.894: W/System.err(4290): at android.view.View.layout(View.java:14817)
08-29 09:48:21.894: W/System.err(4290): at android.view.ViewGroup.layout(ViewGroup.java:4631)
08-29 09:48:21.894: W/System.err(4290): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
08-29 09:48:21.894: W/System.err(4290): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525)
08-29 09:48:21.894: W/System.err(4290): at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
08-29 09:48:21.894: W/System.err(4290): at android.view.View.layout(View.java:14817)
08-29 09:48:21.894: W/System.err(4290): at android.view.ViewGroup.layout(ViewGroup.java:4631)
08-29 09:48:21.894: W/System.err(4290): at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
08-29 09:48:21.894: W/System.err(4290): at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
08-29 09:48:21.904: W/System.err(4290): at android.view.View.layout(View.java:14817)
08-29 09:48:21.904: W/System.err(4290): at android.view.ViewGroup.layout(ViewGroup.java:4631)
08-29 09:48:21.904: W/System.err(4290): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
08-29 09:48:21.904: W/System.err(4290): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525)
08-29 09:48:21.904: W/System.err(4290): at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
08-29 09:48:21.904: W/System.err(4290): at android.view.View.layout(View.java:14817)
08-29 09:48:21.904: W/System.err(4290): at android.view.ViewGroup.layout(ViewGroup.java:4631)
08-29 09:48:21.904: W/System.err(4290): at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
08-29 09:48:21.904: W/System.err(4290): at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
08-29 09:48:21.904: W/System.err(4290): at android.view.View.layout(View.java:14817)
08-29 09:48:21.904: W/System.err(4290): at android.view.ViewGroup.layout(ViewGroup.java:4631)
08-29 09:48:21.904: W/System.err(4290): at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1987)
08-29 09:48:21.904: W/System.err(4290): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1744)
08-29 09:48:21.904: W/System.err(4290): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1000)
08-29 09:48:21.904: W/System.err(4290): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5670)
08-29 09:48:21.904: W/System.err(4290): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
08-29 09:48:21.904: W/System.err(4290): at android.view.Choreographer.doCallbacks(Choreographer.java:574)
08-29 09:48:21.904: W/System.err(4290): at android.view.Choreographer.doFrame(Choreographer.java:544)
08-29 09:48:21.904: W/System.err(4290): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
08-29 09:48:21.904: W/System.err(4290): at android.os.Handler.handleCallback(Handler.java:733)
08-29 09:48:21.904: W/System.err(4290): at android.os.Handler.dispatchMessage(Handler.java:95)
08-29 09:48:21.904: W/System.err(4290): at android.os.Looper.loop(Looper.java:136)
08-29 09:48:21.904: W/System.err(4290): at android.app.ActivityThread.main(ActivityThread.java:5017)
08-29 09:48:21.904: W/System.err(4290): at java.lang.reflect.Method.invokeNative(Native Method)
08-29 09:48:21.904: W/System.err(4290): at java.lang.reflect.Method.invoke(Method.java:515)
08-29 09:48:21.904: W/System.err(4290): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
08-29 09:48:21.904: W/System.err(4290): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
08-29 09:48:21.904: W/System.err(4290): at dalvik.system.NativeStart.main(Native Method)
AbstractMethodError is a dual exception (has both cases of being caught at compile time and cases of being caught at runtime) . And Java docs for this class states "Thrown when an application tries to call an abstract method.".
Abstract methods are function without implementation i.e. they only have defined function signature (a.k.a. header) . So when JVM jumps to an abstract method's entry point, it throws this exception since it doesn't know what to do (function definition is still empty) . So you need to override all abstract functions defined in the class you're extending with actual functions that have implementation. In your case in particular, RecyclerView calls abstract function animateDissapearance when removing an item from its adapter's collection, and it also calls abstract function animateAppearance when adding an item to its adapter's collection. You don't seem to be overriding these functions in your RecyclerView class.
The fix to your exception ends with the previous paragraph. This is just in case you're wondering why would anyone use abstract methods when they don't do anything and even cause exceptions.
Abstract methods (mostly used in libraries and other developer tools) allow the developer to reference, schedule and work with arbitrarily complex unit of work without worrying about its actual implementation. This is especially useful when you're developing libraries since you don't know the cases your users are going to use. I'll give an example that people can, hopefully, easily identify with:
Imagine you are developing a tool that want to support plugins developed by independent developers. To have an even clearer example - let it be an email client. Now, we'll take a look at one situation when your email client should send the email. And suppose you're expecting dev community to develop plugins that backup email copies to hard drive, to cloud storage or any other action that is related to the mail, prior to the sending. You don't and can't know what they are up to, but you know what they need as input and expect at output. So you implement your mail-sending function like this:
boolean sendMail(HashMap<String, String> headers, String body, String recipient, List<DeveloperPlugin> activePlugins) {
//Your parameter validation
for(DeveloperPlugin plugin : activePlugins) {
plugin.runBeforeSendEmailAction(headers, body);
}
//Send email
}
Then you instruct your developer community to store all their logic in a class that extends DeveloperPlugin class (or implements DeveloperPlugin interface) and specifically implement all their actions related to mail that they want to execute before the mail is actually sent, inside the runBeforeSendEmailAction(HashMap<String, String> headers, String body) function of that class (interface) . This solves the biggest problem you face as main module developer - how to ensure application behaves the same no matter what plugin developers implement. It also solves the biggest problem plugin developers face - how do I know what input will my function get and how and when do I call it?
I considerably went overboard with this, but hopefully someone will find it interesting, maybe even helpful.
Cheers! :D
I fixed it by downgrade the android support libraries to 23.1.1 and disabling the change animations :
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
And in the activity class :
//Added the following line just for case
recyclerView.setHasFixedSize(false);
//REMOVE the following line
recyclerView.setItemAnimator(animator);
In the XML add the following line to the RecycleView tag :
android:animateLayoutChanges="false"
And eveything is working fine with me now.

Android App crashing due to classcastexception when using sliding menu library [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
I am getting this error when my app crashes due to Sliding Menu Library
12-31 14:02:54.319: E/AndroidRuntime(4121): java.lang.ClassCastException: android.view.ViewGroup$LayoutParams cannot be cast to android.widget.AbsListView$LayoutParams
12-31 14:02:54.319: E/AndroidRuntime(4121): at android.widget.ListView.setupChild(ListView.java:1826)
12-31 14:02:54.319: E/AndroidRuntime(4121): at android.widget.ListView.makeAndAddView(ListView.java:1793)
12-31 14:02:54.319: E/AndroidRuntime(4121): at android.widget.ListView.fillSpecific(ListView.java:1337)
12-31 14:02:54.319: E/AndroidRuntime(4121): at android.widget.ListView.layoutChildren(ListView.java:1620)
12-31 14:02:54.319: E/AndroidRuntime(4121): at android.widget.AbsListView.onLayout(AbsListView.java:2087)
12-31 14:02:54.319: E/AndroidRuntime(4121): at android.view.View.layout(View.java:14817)
12-31 14:02:54.319: E/AndroidRuntime(4121): at android.view.ViewGroup.layout(ViewGroup.java:4631)
12-31 14:02:54.319: E/AndroidRuntime(4121): at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1055)
12-31 14:02:54.319: E/AndroidRuntime(4121): at android.view.View.layout(View.java:14817)
12-31 14:02:54.319: E/AndroidRuntime(4121): at android.view.ViewGroup.layout(ViewGroup.java:4631)
12-31 14:02:54.319: E/AndroidRuntime(4121): at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1055)
12-31 14:02:54.319: E/AndroidRuntime(4121): at android.view.View.layout(View.java:14817)
12-31 14:02:54.319: E/AndroidRuntime(4121): at android.view.ViewGroup.layout(ViewGroup.java:4631)
12-31 14:02:54.319: E/AndroidRuntime(4121): at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1055)
12-31 14:02:54.319: E/AndroidRuntime(4121): at android.view.View.layout(View.java:14817)
12-31 14:02:54.319: E/AndroidRuntime(4121): at android.view.ViewGroup.layout(ViewGroup.java:4631)
12-31 14:02:54.319: E/AndroidRuntime(4121): at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
12-31 14:02:54.319: E/AndroidRuntime(4121): at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
12-31 14:02:54.319: E/AndroidRuntime(4121): at android.view.View.layout(View.java:14817)
12-31 14:02:54.319: E/AndroidRuntime(4121): at android.view.ViewGroup.layout(ViewGroup.java:4631)
12-31 14:02:54.319: E/AndroidRuntime(4121): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
12-31 14:02:54.319: E/AndroidRuntime(4121): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525)
12-31 14:02:54.319: E/AndroidRuntime(4121): at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
12-31 14:02:54.319: E/AndroidRuntime(4121): at android.view.View.layout(View.java:14817)
12-31 14:02:54.319: E/AndroidRuntime(4121): at android.view.ViewGroup.layout(ViewGroup.java:4631)
12-31 14:02:54.319: E/AndroidRuntime(4121): at com.jeremyfeinstein.slidingmenu.lib.CustomViewAbove.onLayout(CustomViewAbove.java:476)
12-31 14:02:54.319: E/AndroidRuntime(4121): at android.view.View.layout(View.java:14817)
12-31 14:02:54.319: E/AndroidRuntime(4121): at android.view.ViewGroup.layout(ViewGroup.java:4631)
12-31 14:02:54.319: E/AndroidRuntime(4121): at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1055)
12-31 14:02:54.319: E/AndroidRuntime(4121): at android.view.View.layout(View.java:14817)
12-31 14:02:54.319: E/AndroidRuntime(4121): at android.view.ViewGroup.layout(ViewGroup.java:4631)
12-31 14:02:54.319: E/AndroidRuntime(4121): at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
12-31 14:02:54.319: E/AndroidRuntime(4121): at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
12-31 14:02:54.319: E/AndroidRuntime(4121): at android.view.View.layout(View.java:14817)
12-31 14:02:54.319: E/AndroidRuntime(4121): at android.view.ViewGroup.layout(ViewGroup.java:4631)
12-31 14:02:54.319: E/AndroidRuntime(4121): at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1983)
12-31 14:02:54.319: E/AndroidRuntime(4121): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1740)
12-31 14:02:54.319: E/AndroidRuntime(4121): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:996)
12-31 14:02:54.319: E/AndroidRuntime(4121): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5600)
12-31 14:02:54.319: E/AndroidRuntime(4121): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
12-31 14:02:54.319: E/AndroidRuntime(4121): at android.view.Choreographer.doCallbacks(Choreographer.java:574)
12-31 14:02:54.319: E/AndroidRuntime(4121): at android.view.Choreographer.doFrame(Choreographer.java:544)
12-31 14:02:54.319: E/AndroidRuntime(4121): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
12-31 14:02:54.319: E/AndroidRuntime(4121): at android.os.Handler.handleCallback(Handler.java:733)
12-31 14:02:54.319: E/AndroidRuntime(4121): at android.os.Handler.dispatchMessage(Handler.java:95)
12-31 14:02:54.319: E/AndroidRuntime(4121): at android.os.Looper.loop(Looper.java:136)
12-31 14:02:54.319: E/AndroidRuntime(4121): at android.app.ActivityThread.main(ActivityThread.java:5001)
12-31 14:02:54.319: E/AndroidRuntime(4121): at java.lang.reflect.Method.invokeNative(Native Method)
12-31 14:02:54.319: E/AndroidRuntime(4121): at java.lang.reflect.Method.invoke(Method.java:515)
12-31 14:02:54.319: E/AndroidRuntime(4121): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
12-31 14:02:54.319: E/AndroidRuntime(4121): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
12-31 14:02:54.319: E/AndroidRuntime(4121): at dalvik.system.NativeStart.main(Native Method)
can anyone help me in this issue. i tried to download fresh copy of library and use, but even then it is not solved. im compiling all my project dependent projects and app with android 5.0
Check/Organise your imports(ctrl + shift + o, in Eclipse) in CustomViewAbove.java and ensure that if LayoutParams have been used anywhere, they are from the package of android.widget.AbsListView.
Basically that is what your error is telling you:
12-31 14:02:54.319: E/AndroidRuntime(4121): java.lang.ClassCastException:
android.view.ViewGroup$LayoutParams cannot be cast to android.widget.AbsListView$LayoutParams
If LayoutParams are being used at multiple places(other than line no. 476), then need to import both packages accordingly.

Categories

Resources