Verified
Status Update
Comments
am...@google.com <am...@google.com>
am...@google.com <am...@google.com> #2
[Comment deleted]
yb...@google.com <yb...@google.com>
ta...@gmail.com <ta...@gmail.com> #3
[Comment deleted]
am...@google.com <am...@google.com> #4
Also of note is the adb error when trying to install bad APK: INSTALL_FAILED_DEXOPT
go...@gmail.com <go...@gmail.com> #5
load dex files over 5Gb. -> load dex files over 5Mb.
go...@gmail.com <go...@gmail.com> #6
Same here! Looking forward to a solution :)
Android Studio version: 0.8.12
buildToolsVersion 21.0.1
Gradle 1.11
Android Studio version: 0.8.12
buildToolsVersion 21.0.1
Gradle 1.11
yb...@google.com <yb...@google.com> #7
There is already an option in dx allowing to force generation of smaller dex files:
--set-max-idx-number=<value>
Unfortunately changing the default is not a solution since the linearAlloc limit can be reached at very different levels depending on the classes hierarchy and other criteria.
In addition for most applications, moving to multidex will only help to workaround the linearalloc limit for the installation. But the application will still crash against the same limit at execution. The only working use case where I know multidex can help with linearalloc is when the apk does not contains one application but distinct pieces running in separate process.
--set-max-idx-number=<value>
Unfortunately changing the default is not a solution since the linearAlloc limit can be reached at very different levels depending on the classes hierarchy and other criteria.
In addition for most applications, moving to multidex will only help to workaround the linearalloc limit for the installation. But the application will still crash against the same limit at execution. The only working use case where I know multidex can help with linearalloc is when the apk does not contains one application but distinct pieces running in separate process.
ta...@gmail.com <ta...@gmail.com> #8
Thanks for your quick response.
It's nice to know about that command line option. I do not see it in the output of 'dx --help', might be good to add that.
I'm not very familiar with the 'linearAlloc limit' issue outside of the context of the dexopt step. My sample app is able to run once the lower idx value is set, although I do not actually call into any of the library code that is bundled with the app. I assume it's undefined when/if the 'linearAlloc limit' will be hit in a large application on gb.
I'm a bit confused as to the platform compatibility of multidex given the 'linearAlloc limit' bug. What specific versions of Android are supported? The multidex code implies back to v4 (https://android.googlesource.com/platform/frameworks/multidex/+/master/library/src/android/support/multidex/MultiDex.java ) but it would seem that ICS is the earliest supported platform. Is this correct?
It's nice to know about that command line option. I do not see it in the output of 'dx --help', might be good to add that.
I'm not very familiar with the 'linearAlloc limit' issue outside of the context of the dexopt step. My sample app is able to run once the lower idx value is set, although I do not actually call into any of the library code that is bundled with the app. I assume it's undefined when/if the 'linearAlloc limit' will be hit in a large application on gb.
I'm a bit confused as to the platform compatibility of multidex given the 'linearAlloc limit' bug. What specific versions of Android are supported? The multidex code implies back to v4 (
yb...@google.com <yb...@google.com> #9
The option is not documented in --help because it was designed for testing and we're not capable of documenting a reliable way to use it as a workaround of the linearalloc limit.
The linearalloc limit is reached when loading classes. At install time dexopt is loading all classes contained in the dex so it's facing the limit immediately. At execution the limit may be reached after some delay dependending of the usage you have of the packaged classes. If you face it at install time but not at execution, this means you never trigger the loading of some classes. In a real application those never loaded classes should have been shrinked away manually or by Proguard. The exception is when there are different groups of classes in the dex files used in separate process.
About multidex library supported versions I've merged recently a change to try to be clearerhttps://android-review.googlesource.com/#/c/108023/
The summary is that the library should work down to API 4 (Donut), but below ICS applications will probably be hit by the linearalloc limit
The linearalloc limit is reached when loading classes. At install time dexopt is loading all classes contained in the dex so it's facing the limit immediately. At execution the limit may be reached after some delay dependending of the usage you have of the packaged classes. If you face it at install time but not at execution, this means you never trigger the loading of some classes. In a real application those never loaded classes should have been shrinked away manually or by Proguard. The exception is when there are different groups of classes in the dex files used in separate process.
About multidex library supported versions I've merged recently a change to try to be clearer
The summary is that the library should work down to API 4 (Donut), but below ICS applications will probably be hit by the linearalloc limit
pr...@gmail.com <pr...@gmail.com> #10
for Android studio use:
dexOptions {
additionalParameters = ['--multi-dex', '--set-max-idx-number=40000']
}
dexOptions {
additionalParameters = ['--multi-dex', '--set-max-idx-number=40000']
}
yb...@google.com <yb...@google.com> #11
I still have this issue and it's driving me nuts
am...@google.com <am...@google.com> #14
Issue has been fixed and released in 25.1.1 support lib
ta...@gmail.com <ta...@gmail.com> #15
Version 25.1.1 doesn't seem to solve the issue for me.
My use case could be a little different (maybe easier) from OP's.
1. StaggeredGridLayoutManager with multiple columns (eg. 2)
2. Single item view type - ImageView wrapped in CardView (both layout_width="match_parent", layout_height="wrap_content", ImageView:adjustViewBounds="true")
3. Load 1,000 items, performs image loading with Glide (All images stored on device storage)
4. Flinging the list up and down.
Same exception will be thrown randomly.
PS: As OP suggested, I do StaggeredGridLayoutManager.setItemPrefetchEnabled(false); to prevent the issue from happening.
My use case could be a little different (maybe easier) from OP's.
1. StaggeredGridLayoutManager with multiple columns (eg. 2)
2. Single item view type - ImageView wrapped in CardView (both layout_width="match_parent", layout_height="wrap_content", ImageView:adjustViewBounds="true")
3. Load 1,000 items, performs image loading with Glide (All images stored on device storage)
4. Flinging the list up and down.
Same exception will be thrown randomly.
PS: As OP suggested, I do StaggeredGridLayoutManager.setItemPrefetchEnabled(false); to prevent the issue from happening.
sk...@googlemail.com <sk...@googlemail.com> #16
We still have the problem with 25.1.1 using RecyclerView
java.lang.IllegalArgumentException: Pixel distance must be non-negative
at android.support.v7.widget.GapWorker$LayoutPrefetchRegistryImpl.addPosition(GapWorker.java:110) at android.support.v7.widget.LinearLayoutManager.collectPrefetchPositionsForLayoutState(LinearLayoutManager.java:1202) at android.support.v7.widget.LinearLayoutManager.collectAdjacentPrefetchPositions(LinearLayoutManager.java:1300)
at android.support.v7.widget.GapWorker$LayoutPrefetchRegistryImpl.collectPrefetchPositionsFromView(GapWorker.java:94)
at android.support.v7.widget.GapWorker.buildTaskList(GapWorker.java:213)
at android.support.v7.widget.GapWorker.prefetch(GapWorker.java:343)
at android.support.v7.widget.GapWorker.run(GapWorker.java:370)
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:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
java.lang.IllegalArgumentException: Pixel distance must be non-negative
at android.support.v7.widget.GapWorker$LayoutPrefetchRegistryImpl.addPosition(GapWorker.java:110) at android.support.v7.widget.LinearLayoutManager.collectPrefetchPositionsForLayoutState(LinearLayoutManager.java:1202) at android.support.v7.widget.LinearLayoutManager.collectAdjacentPrefetchPositions(LinearLayoutManager.java:1300)
at android.support.v7.widget.GapWorker$LayoutPrefetchRegistryImpl.collectPrefetchPositionsFromView(GapWorker.java:94)
at android.support.v7.widget.GapWorker.buildTaskList(GapWorker.java:213)
at android.support.v7.widget.GapWorker.prefetch(GapWorker.java:343)
at android.support.v7.widget.GapWorker.run(GapWorker.java:370)
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:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
cc...@android.com <cc...@android.com> #17
Reopening to investigate repros in 25.1.1
[Deleted User] <[Deleted User]> #18
Another report: we got the same thing on support library 25.1.1
Here is the crash log:
Fatal Exception: java.lang.IllegalArgumentException: Pixel distance must be non-negative
at android.support.v7.widget.GapWorker$LayoutPrefetchRegistryImpl.addPosition(GapWorker.java:110)
at android.support.v7.widget.GridLayoutManager.collectPrefetchPositionsForLayoutState(GridLayoutManager.java:514)
at android.support.v7.widget.LinearLayoutManager.collectAdjacentPrefetchPositions(LinearLayoutManager.java:1300)
at android.support.v7.widget.GapWorker$LayoutPrefetchRegistryImpl.collectPrefetchPositionsFromView(GapWorker.java:94)
at android.support.v7.widget.GapWorker.buildTaskList(GapWorker.java:213)
at android.support.v7.widget.GapWorker.prefetch(GapWorker.java:343)
at android.support.v7.widget.GapWorker.run(GapWorker.java:370)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5237)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:707)
Here is the crash log:
Fatal Exception: java.lang.IllegalArgumentException: Pixel distance must be non-negative
at android.support.v7.widget.GapWorker$LayoutPrefetchRegistryImpl.addPosition(GapWorker.java:110)
at android.support.v7.widget.GridLayoutManager.collectPrefetchPositionsForLayoutState(GridLayoutManager.java:514)
at android.support.v7.widget.LinearLayoutManager.collectAdjacentPrefetchPositions(LinearLayoutManager.java:1300)
at android.support.v7.widget.GapWorker$LayoutPrefetchRegistryImpl.collectPrefetchPositionsFromView(GapWorker.java:94)
at android.support.v7.widget.GapWorker.buildTaskList(GapWorker.java:213)
at android.support.v7.widget.GapWorker.prefetch(GapWorker.java:343)
at android.support.v7.widget.GapWorker.run(GapWorker.java:370)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5237)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:707)
cc...@android.com <cc...@android.com> #19
#19 and #21 are slightly different from the original issue, since they're from LinearLayoutManager and GridLayoutManager. I see how this may be occurring, and will put in a fix.
As to the case in #18, I'm not sure how StaggeredGridLayoutManager could have these issues in 25.1.1, looking at the code (and scrolling around manually in a 2 column staggered grid), I'm not seeing the issue. Are you sure you're both on 25.1.1, and seeing StaggeredGridLayoutManager in the stack trace?
As to the case in #18, I'm not sure how StaggeredGridLayoutManager could have these issues in 25.1.1, looking at the code (and scrolling around manually in a 2 column staggered grid), I'm not seeing the issue. Are you sure you're both on 25.1.1, and seeing StaggeredGridLayoutManager in the stack trace?
bf...@gmail.com <bf...@gmail.com> #20
Getting the same stacktrace with RecyclerView for support library 25.1.1
Fatal Exception: java.lang.IllegalArgumentException: Pixel distance must be non-negative
at android.support.v7.widget.GapWorker$LayoutPrefetchRegistryImpl.addPosition(GapWorker.java:110)
at android.support.v7.widget.LinearLayoutManager.collectPrefetchPositionsForLayoutState(LinearLayoutManager.java:1202)
at android.support.v7.widget.LinearLayoutManager.collectAdjacentPrefetchPositions(LinearLayoutManager.java:1300)
at android.support.v7.widget.GapWorker$LayoutPrefetchRegistryImpl.collectPrefetchPositionsFromView(GapWorker.java:94)
at android.support.v7.widget.GapWorker.buildTaskList(GapWorker.java:213)
at android.support.v7.widget.GapWorker.prefetch(GapWorker.java:343)
at android.support.v7.widget.GapWorker.run(GapWorker.java:370)
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:6119)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Fatal Exception: java.lang.IllegalArgumentException: Pixel distance must be non-negative
at android.support.v7.widget.GapWorker$LayoutPrefetchRegistryImpl.addPosition(GapWorker.java:110)
at android.support.v7.widget.LinearLayoutManager.collectPrefetchPositionsForLayoutState(LinearLayoutManager.java:1202)
at android.support.v7.widget.LinearLayoutManager.collectAdjacentPrefetchPositions(LinearLayoutManager.java:1300)
at android.support.v7.widget.GapWorker$LayoutPrefetchRegistryImpl.collectPrefetchPositionsFromView(GapWorker.java:94)
at android.support.v7.widget.GapWorker.buildTaskList(GapWorker.java:213)
at android.support.v7.widget.GapWorker.prefetch(GapWorker.java:343)
at android.support.v7.widget.GapWorker.run(GapWorker.java:370)
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:6119)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
yu...@gmail.com <yu...@gmail.com> #21
[Comment deleted]
em...@gmail.com <em...@gmail.com> #22
I have the same crash using support lib 25.2.0. Is there a different issue to track this crash from a LinearLayoutManager, looks like it was opened for the StaggeredGridLayoutManager
Pixel distance must be non-negative
java.lang.IllegalArgumentException: Pixel distance must be non-negative
at android.support.v7.widget.GapWorker$LayoutPrefetchRegistryImpl.addPosition(GapWorker.java:110)
at android.support.v7.widget.LinearLayoutManager.collectPrefetchPositionsForLayoutState(LinearLayoutManager.java:1202)
at android.support.v7.widget.LinearLayoutManager.collectAdjacentPrefetchPositions(LinearLayoutManager.java:1300)
at android.support.v7.widget.GapWorker$LayoutPrefetchRegistryImpl.collectPrefetchPositionsFromView(GapWorker.java:94)
at android.support.v7.widget.GapWorker.buildTaskList(GapWorker.java:213)
at android.support.v7.widget.GapWorker.prefetch(GapWorker.java:343)
at android.support.v7.widget.GapWorker.run(GapWorker.java:370)
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:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Pixel distance must be non-negative
java.lang.IllegalArgumentException: Pixel distance must be non-negative
at android.support.v7.widget.GapWorker$LayoutPrefetchRegistryImpl.addPosition(GapWorker.java:110)
at android.support.v7.widget.LinearLayoutManager.collectPrefetchPositionsForLayoutState(LinearLayoutManager.java:1202)
at android.support.v7.widget.LinearLayoutManager.collectAdjacentPrefetchPositions(LinearLayoutManager.java:1300)
at android.support.v7.widget.GapWorker$LayoutPrefetchRegistryImpl.collectPrefetchPositionsFromView(GapWorker.java:94)
at android.support.v7.widget.GapWorker.buildTaskList(GapWorker.java:213)
at android.support.v7.widget.GapWorker.prefetch(GapWorker.java:343)
at android.support.v7.widget.GapWorker.run(GapWorker.java:370)
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:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
xl...@gmail.com <xl...@gmail.com> #23
got the same crash with 25.1.1 annd 25.2.0.
here you can find the demo project to reproduce this issue:https://github.com/longerian/VlayoutDemo
here you can find the demo project to reproduce this issue:
bf...@gmail.com <bf...@gmail.com> #24
Faced the same issue with 25.1.1. Fixed it using
StaggeredGridLayoutManager.setItemPrefetchEnabled(false);
or
LinearLayoutManager.setItemPrefetchEnabled(false);
StaggeredGridLayoutManager.setItemPrefetchEnabled(false);
or
LinearLayoutManager.setItemPrefetchEnabled(false);
xl...@gmail.com <xl...@gmail.com> #25
am...@google.com <am...@google.com> #26
The issue is fixed in latest support libraries. If you come across the issue again, please let us know by raising a new issue along with the sample code which reproduces the issue.
Thanks.
Thanks.
Description
Version used: 25.1.0
Theme used: Theme.AppCompat.Light.DarkActionBar
Devices/Android versions reproduced on: Android API 23 AVD emulator, Android 5.1 user devices
- Relevant code to trigger the issue.
The important parts of the code:
1. Uses StaggeredGridLayoutManager with multiple columns.
2. Some of the items are full span: `StaggeredGridLayoutManager.LayoutParams.setFullSpan(true)`
3. Call `RecyclerView.Adapter.notifyItemChanged()` on UI thread (e.g. post delayed Handler)
When running the example app, try flinging the RecyclerView up and down several times. It will eventually force close.
- Stack trace:
java.lang.IllegalArgumentException: Pixel distance must be non-negative
at android.support.v7.widget.GapWorker$LayoutPrefetchRegistryImpl.addPosition(GapWorker.java:110)
at android.support.v7.widget.StaggeredGridLayoutManager.collectAdjacentPrefetchPositions(StaggeredGridLayoutManager.java:2109)
at android.support.v7.widget.GapWorker$LayoutPrefetchRegistryImpl.collectPrefetchPositionsFromView(GapWorker.java:94)
at android.support.v7.widget.GapWorker.buildTaskList(GapWorker.java:213)
at android.support.v7.widget.GapWorker.prefetch(GapWorker.java:343)
at android.support.v7.widget.GapWorker.run(GapWorker.java:370)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)