java.lang.OutOfMemoryError: GC overhead limit exceeded

After upgrading Google Play services library from 9.4.0 to 10.2.0 Gradle build fails with following error:

Information: Gradle tasks [:app:assembleDebug]
Error: UNEXPECTED TOP-LEVEL ERROR:
Error: java.lang.OutOfMemoryError: GC overhead limit exceeded
Error: Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: java.lang.UnsupportedOperationException
Information:BUILD FAILED

Android Studio - bindView called multiple times for each listView row

Issue

bindView inside a custom CursorAdapter is called 6-7 times for each row.

Resolution

There is no direct way to control when bindView is called. Android operating system does it as and when required it in order to properly measure and draw the layout. In this particular case the issue was caused by setting layout width to wrap_content in the ListView layout. Changing this to match_parent fully resolved the issue and bindView is now called only once for each ListView row.



Newsletter

Subscribe to receive occasional updates on new posts.
Your email will not be used for any other purpose and you can unsubscribe at any time.
Please wait
Privacy Policy