Assigned
Status Update
Comments
ad...@google.com <ad...@google.com>
yb...@google.com <yb...@google.com> #2
Forgot to note the environment.
This crash occurs on only API 21.
This crash occurs on only API 21.
em...@gmail.com <em...@gmail.com> #3
This crash occurs on API 22 and 23 when the user doesn't have Google Play installed. Related discussions: https://stackoverflow.com/q/41025200/842697
Description
Version used: 1.1.0
What steps will reproduce the problem?
1. Try to use ArchTaskExecutor directly, because of JUnit5
JUnit5 (supported via
```
class InstantTaskExecutorExtension : BeforeEachCallback, AfterEachCallback {
@SuppressLint("RestrictedApi")
override fun beforeEach(context: ExtensionContext) {
ArchTaskExecutor.getInstance().setDelegate(object : TaskExecutor() {
override fun executeOnDiskIO(runnable: Runnable) {
runnable.run()
}
override fun postToMainThread(runnable: Runnable) {
runnable.run()
}
override fun isMainThread(): Boolean {
return true
}
})
}
override fun afterEach(context: ExtensionContext?) {
ArchTaskExecutor.getInstance().setDelegate(null)
}
}
```
Used like:
```
@ExtendWith(InstantTaskExecutorExtension::class)
internal class AuthenticationInterceptorTest { ... }
```
Works great. However, I recently decided to move code like this to a common module so it can be consumed by more than just my `app` module. So I ended up putting it in the main sourceSet (so it can be consumed via `"testImplementation project(:junit5-extensions)"`. That's when Lint complained I was exceeding my access rights to `ArchTaskExecutor`. I can suppress it, of course, but this seems non-ideal. Why is that restriction on that class?