[Kotlin][Android]disable runBlocking checker in a UI thread

This post is completely my personal memo. Recent kotlinx.coroutines has raising exception when runBlocking runs on a UI thread by default. The runBlocking is used to block current thread interruptibly until its completion. https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/run-blocking.html https://github.com/Kotlin/kotlinx.coroutines/blob/7764e43c6fe9640615747f7830e8aae1b9bc26d2/docs/basics.md#bridging-blocking-and-non-blocking-worlds In 0.25.0, the runBlocking has https://github.com/Kotlin/kotlinx.coroutines/issues/464 . As a workaround, we can disable the checker as below. https://github.com/Kotlin/kotlinx.coroutines/pull/458#issuecomment-408737581 https://github.com/Kotlin/kotlinx.coroutines/issues/227 [update]…More

[Android]Relax “Restrictions on non-SDK interfaces” on Android P

Android P has a feature of Restrictions on non-SDK interfaces. => https://developer.android.com/preview/restrictions-non-sdk-interfaces If you have a method like below, you will face java.lang.NoSuchMethodException: setAnimationScales [class [F] error. This is because of the non-sdk interface feature. https://github.com/KazuCocoa/DroidTestHelper/blob/3781fa40a6c9dfd34e1cb94ae230a98931af3313/droidtesthelperlib/src/main/java/com/kazucocoa/droidtesthelperlib/HandleAnimations.kt#L23 To avoid the error, we can call below adb commands. After this, calling setAnimationScales succeeds. I’ve appended the note…More

[Android]Use PermissionRequester to get permissions

I’m using composer to handle instrumented tests. GrantPermissionRule has introduced for the andorid test support library, [Android]Checking Android Testing Support Library 1.0. The Rule work as @Rule in JUnit4. We’d like to clean screenshots every time. But we need some permissions to clean them. To achieve it, we can use PermissionRequester to get permissions. In…More

[Android]some mocking features work only on Android P+

One of my colleagues told me Mockk. The library is pure Kotlin mocking library. An interesting thing for me is Android instrumentation support. I had a question when I saw that why Android P was a limitation. Since it provide mocking feature for final classes / objects in instrumentation tests. I investigated a bit and…More