ListView Pop-Up Context Menu broken in Android 7 (API 24)

Issue

ListView context menu pop-up doesn't work properly in Android 7.0 and 7.1 Nougat (API 24 and API 25).

Instead of the full menu appearing in the middle of the screen, it now appears collapsed to a single item and either at the very top or at the very bottom of the screen.

Here is the expected behaviour:

Here is how the context menu looks in Android 7.1.1:

The app uses com.android.support:appcompat-v7 library and Theme.Holo.Light theme.

Read more: ListView Pop-Up Context Menu broken in Android 7 (API 24)

The number of method references in a .dex file cannot exceed 64k

Gradle build fails with error "The number of method references in a .dex file cannot exceed 64k "

As the error suggests you cannot have more than 64k methods in one classes.dex file. One way around this is to use enable MultiDex in your build.gradle


multiDexEnabled true

Read more: The number of method references in a .dex file cannot exceed 64k

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

Read more: java.lang.OutOfMemoryError: GC overhead limit exceeded

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.

Read more: Android Studio - bindView called multiple times for each listView row