Kotlinx.coroutines: java.util.ServiceConfigurationError: Couldn't read jar:file:/data/app/xxx-1/base.apk!/META-INF/services/kotlinx.coroutines.internal.MainDispatcherFactory

Created on 1 Jan 2019  路  7Comments  路  Source: Kotlin/kotlinx.coroutines

java.util.ServiceConfigurationError: Couldn't read jar:file:/data/app/xxxxxx-1/base.apk!/META-INF/services/kotlinx.coroutines.internal.MainDispatcherFactory
at java.util.ServiceLoader$ServiceIterator.readClass(ServiceLoader.java:245)
at java.util.ServiceLoader$ServiceIterator.hasNext(ServiceLoader.java:202)
at kotlin.collections.p.a(_Collections.kt:1132)
at kotlin.collections.p.b(_Collections.kt:1165)
at kotlin.collections.p.a(_Collections.kt:1156)
at kotlinx.coroutines.bj.(Dispatchers.kt:96)
at kotlinx.coroutines.an.b(Dispatchers.kt:53)
at xxxxxx.SelectViewModel.(SelectViewModel.kt:19)
at java.lang.Class.newInstance(Native Method)
at android.arch.lifecycle.t$b.a(ViewModelProvider.java:146)
at android.arch.lifecycle.u$a.a(ViewModelProviders.java:159)
at android.arch.lifecycle.t.a(ViewModelProvider.java:130)
at android.arch.lifecycle.t.a(ViewModelProvider.java:98)
at xxxxxx.SelectPrinterActivity$g.b(SelectPrinterActivity.kt:31)
at xxxxxx.SelectPrinterActivity$g.a(SelectPrinterActivity.kt:26)
at kotlin.m.a(LazyJVM.kt:74)
at xxxxxx.SelectPrinterActivity.o(SelectPrinterActivity.kt)
at xxxxxx.SelectPrinterActivity.k(SelectPrinterActivity.kt:83)
at xxxxxx.BaseActivity.onCreate(BaseActivity.kt:23)
at android.app.Activity.performCreate(Activity.java:6285)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.access$900(ActivityThread.java:150)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.util.ConcurrentModificationException
at java.util.HashMap$HashIterator.nextEntry(HashMap.java:787)
at java.util.HashMap$KeyIterator.next(HashMap.java:814)
at java.util.jar.JarVerifier.readCertificates(JarVerifier.java:266)
at java.util.jar.JarFile.getInputStream(JarFile.java:380)
at libcore.net.url.JarURLConnectionImpl.getInputStream(JarURLConnectionImpl.java:222)
at java.net.URL.openStream(URL.java:470)
at java.util.ServiceLoader$ServiceIterator.readClass(ServiceLoader.java:224)
... 30 more

kotlin :1.2.10
kotlinxCoroutines锛歝ore 1.0.1 android:1.0.1

@JakeWharton this error is Occasionally present锛沷nly when usb "by lazy" or "GlobalScope.async(Dispatchers.Main)" ;is this a bug?

Most helpful comment

We also experience the same issue on Xiaomi Redmi Note 2 (5.0.2), P8 Lite (5.0.1), LenovoTAB2 A7-30DC (5.0.1), Lenovo A6010 (5.0.2) with:

  • kotlin 1.3.21,
  • coroutines 1.1.1,
  • release build with Proguard obfuscation

Unfortunately, don't have access to such device yet and can't reproduce locally...

All 7 comments

someone can help me?thanks

When and how it reproduces? Does it reproduce under emulator? Under what Android version?

@elizarov thanks ! it reproduce under in real device,Android verion is 5.1.1,

Seeing the same on Android 5.0, 5.0.1 and 5.0.2

We are seeing the same problem on firebase and on our test-devices.
minSdkVersion 21
targetSdkVersion 28
kotlinVersion 1.3.20
kotlinCoroutine 1.1.0

This is only affecting Android 5.x devices, and it's possible to reproduce it on Android Emulator.

open class ScopedViewModel : ViewModel(), CoroutineScope {
    override val coroutineContext = Dispatchers.Main + Job()
    ...
}
class CrashhViewModel constructor() : ScopedViewModel() {
    fun crash() {
        launch {
        // This will crash
        }
    }
}

For some reason Samsung devices is not affected by this.

We also experience the same issue on Xiaomi Redmi Note 2 (5.0.2), P8 Lite (5.0.1), LenovoTAB2 A7-30DC (5.0.1), Lenovo A6010 (5.0.2) with:

  • kotlin 1.3.21,
  • coroutines 1.1.1,
  • release build with Proguard obfuscation

Unfortunately, don't have access to such device yet and can't reproduce locally...

Should be fixed in 1.3.3

Was this page helpful?
0 / 5 - 0 ratings

Related issues

altavir picture altavir  路  44Comments

SUPERCILEX picture SUPERCILEX  路  40Comments

elizarov picture elizarov  路  45Comments

Tolriq picture Tolriq  路  50Comments

elizarov picture elizarov  路  62Comments