Why do I get “unresolved reference” error for my view’s name/ID when I type it in Kotlin?

The ability to refer to a view directly by it’s ID/name in Kotlin is called “synthetic properties” and it is a feature of a project plugin called Kotlin Android Extensions. Google and JetBrains decided to deprecate Kotlin Android Extensions, meaning they no longer support it, and discourage you from using it. Ever since it was … Read more

Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0

Run the Gradle build with a command line argument –warning-mode=all to see what exactly the deprecated features are. It will give you a detailed description of found issues with links to the Gradle docs for instructions how to fix your build. Adding –stacktrace to that, you will also be able to pinpoint where the warning … Read more

Difference between List and Array types in Kotlin

Arrays and lists (represented by List<T> and its subtype MutableList<T>) have many differences, here are the most significant ones: Array<T> is a class with known implementation: it’s a sequential fixed-size memory region storing the items (and on JVM it is represented by Java array). List<T> and MutableList<T> are interfaces which have different implementations: ArrayList<T>, LinkedList<T> … Read more

Updating Paging 3 alpha to stable cause indexing issue Android

I noticed you filed a bug here: https://issuetracker.google.com/204328119, but I also wanted to update this answer for other future people reading this issue on SO. The core issue is that you are starting collection on Paging before ViewPager is ready to start binding this items. You should use lifecycleScope.launchWhenCreated instead of lifecycleScope.launc to fix this: … Read more

How to improve image segmentation using the watershed?

A description of how to apply the watershed algorithm in OpenCV is here, although it is in Python. The documentation also contains some potentially useful examples. Since you already have a binary image, all that’s left is to apply the Euclidean Distance Transform (EDT) and the watershed function. So instead of Imgproc.grabCut(srcImage, firstMask, rect, bg, … Read more

startForeground fail after upgrade to Android 8.1

After some tinkering for a while with different solutions i found out that one must create a notification channel in Android 8.1 and above. private fun startForeground() { val channelId = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { createNotificationChannel(“my_service”, “My Background Service”) } else { // If earlier version channel ID is not used // https://developer.android.com/reference/android/support/v4/app/NotificationCompat.Builder.html#NotificationCompat.Builder(android.content.Context) “” … Read more