firebase-android-sdk icon indicating copy to clipboard operation
firebase-android-sdk copied to clipboard

Crash: java.io.IOException: Invalid argument

Open gaoxu19930112 opened this issue 3 weeks ago • 3 comments

[REQUIRED] Describe your environment

  • Android Studio version: Build #AI-251.26094.121.2513.14007798, built on August 28, 2025
  • Firebase Component: crashlytics&analytics&config&messaging&firebase-core
  • Component version: "34.2.0" (FirebaseBOM)

[REQUIRED] Step 3: Describe the problem

          Fatal Exception: java.io.IOException: Invalid argument
       at java.io.UnixFileSystem.canonicalize0(UnixFileSystem.java)
       at java.io.UnixFileSystem.canonicalize0(UnixFileSystem.java:245)
       at java.io.UnixFileSystem.canonicalize(UnixFileSystem.java:192)
       at java.io.File.getCanonicalPath(File.java:616)
       at java.io.File.getCanonicalFile(File.java:652)
       at androidx.datastore.core.FileStorage.createConnection(FileStorage.kt:48)
       at androidx.datastore.core.DataStoreImpl$storageConnectionDelegate$1.invoke(DataStoreImpl.kt:181)
       at androidx.datastore.core.DataStoreImpl$storageConnectionDelegate$1.invoke(DataStoreImpl.kt:180)
       at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:83)
       at androidx.datastore.core.DataStoreImpl.getStorageConnection$datastore_core_release(DataStoreImpl.kt:183)
       at androidx.datastore.core.DataStoreImpl$coordinator$2.invoke(DataStoreImpl.kt:184)
       at androidx.datastore.core.DataStoreImpl$coordinator$2.invoke(DataStoreImpl.kt:184)
       at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:83)
       at androidx.datastore.core.DataStoreImpl.getCoordinator(DataStoreImpl.kt:184)
       at androidx.datastore.core.DataStoreImpl.readAndInitOrPropagateAndThrowFailure(DataStoreImpl.kt:264)
       at androidx.datastore.core.DataStoreImpl.access$readAndInitOrPropagateAndThrowFailure(DataStoreImpl.kt:48)
       at androidx.datastore.core.DataStoreImpl$readState$2.invokeSuspend(DataStoreImpl.kt:218)
       at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
       at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:101)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1156)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:651)
       at com.google.firebase.concurrent.CustomThreadFactory.lambda$newThread$0$com-google-firebase-concurrent-CustomThreadFactory(CustomThreadFactory.java:47)
       at com.google.firebase.concurrent.CustomThreadFactory$$ExternalSyntheticLambda0.run(D8$$SyntheticClass)
       at java.lang.Thread.run(Thread.java:1119)

Relevant Code:

  private fun initFirebaseConfig() {

        try {
            FirebaseApp.initializeApp(this)
            val remoteConfig: FirebaseRemoteConfig = Firebase.remoteConfig
            val configSettings = remoteConfigSettings {
                minimumFetchIntervalInSeconds = 3600
            }
            remoteConfig.setConfigSettingsAsync(configSettings)
            remoteConfig.setDefaultsAsync(R.xml.remote_config_defaults)
            remoteConfig.addOnConfigUpdateListener(object : ConfigUpdateListener {
                override fun onUpdate(configUpdate : ConfigUpdate) {
                    MyLog.e("remoteConfig", "Updated keys: " + configUpdate.updatedKeys);

                    if (configUpdate.updatedKeys.contains("ssl_pinning_enabled")) {
                        remoteConfig.activate().addOnCompleteListener {
                            MyDataStore.setSslPinningEnabled(remoteConfig.getBoolean("ssl_pinning_enabled"))
                          
                        }
                    }
                }

                override fun onError(error : FirebaseRemoteConfigException) {
                    MyLog.e("remoteConfig", "Config update error with code: " + error.code+"   "+ error)
                }
            })
            MyDataStore.setSslPinningEnabled(remoteConfig.getBoolean("ssl_pinning_enabled"))
            MyLog.e("ssl_pinning_enabled", remoteConfig.getBoolean("ssl_pinning_enabled").toString())
        } catch (e: Throwable){
//            MyLog.e("Firebase error: $e")
        }
    }

gaoxu19930112 avatar Nov 26 '25 06:11 gaoxu19930112

Hi @gaoxu19930112, thank you for reaching out. Based on the stacktrace you shared, It looks the exception is not caused by Firebase. I tried reproducing the issue with the code snippet you shared, however, I did not encounter the exception. I tried calling the initFirebaseConfig in Application class or in MainActivity, but I don't see the error.

To get a better understanding, can you answer the question below:

  • By any chance, were you able to reproduce it?
  • You seem to be using Datastore MyDataStore.setSslPinningEnabled, could you try removing them and see if the issue will go away? Also, can you share the Datastore dependency your using?

Also , I notice that you're not using the latest SDK version. Could you try using the latest Firebase SDK (v34.6.0) ? We usually suggests to always use the latest version to ensure that you have the latest updates and bug fixes.

lehcar09 avatar Nov 28 '25 03:11 lehcar09

  • 您似乎正在使用 Datastore MyDataStore.setSslPinningEnabled,能否尝试移除它,看看问题是否消失?另外,能否分享一下Datastore您正在使用的依赖项?
  • I'm sorry, I cannot fix this issue. I discovered it through Firebase monitoring, and it only occurs on a small number of user devices.
  • I didn't have this problem with the previous Firebase version 32.6.0. Because I needed to comply with Google's 16k requirement, I upgraded Firebase to version 34.2.0, and that's when the problem started appearing.
  • | | +--- androidx.datastore:datastore-preferences:1.0.0 -> 1.1.7 | | | \--- androidx.datastore:datastore-preferences-android:1.1.7 | | | +--- androidx.datastore:datastore:1.1.7 | | | | \--- androidx.datastore:datastore-android:1.1.7 | | | | +--- androidx.annotation:annotation:1.2.0 -> 1.8.1 | | | | | \--- androidx.annotation:annotation-jvm:1.8.1 | | | | | \--- org.jetbrains.kotlin:kotlin-stdlib:1.7.10 -> 2.1.0 (*) | | | | +--- androidx.datastore:datastore-core:1.1.7 | | | | | \--- androidx.datastore:datastore-core-android:1.1.7 | | | | | +--- androidx.annotation:annotation:1.7.0 -> 1.8.1 (*) | | | | | +--- org.jetbrains.kotlin:kotlin-parcelize-runtime:1.9.22 | | | | | | +--- org.jetbrains.kotlin:kotlin-stdlib:1.9.22 -> 2.1.0 (*) | | | | | | \--- org.jetbrains.kotlin:kotlin-android-extensions-runtime:1.9.22 | | | | | | \--- org.jetbrains.kotlin:kotlin-stdlib:1.9.22 -> 2.1.0 (*) | | | | | +--- org.jetbrains.kotlin:kotlin-stdlib:1.8.22 -> 2.1.0 (*) | | | | | +--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3 -> 1.9.0 (*) | | | | | +--- androidx.datastore:datastore:1.1.7 (c) | | | | | +--- androidx.datastore:datastore-core-okio:1.1.7 (c) | | | | | +--- androidx.datastore:datastore-preferences:1.1.7 (c) | | | | | +--- androidx.datastore:datastore-preferences-core:1.1.7 (c) | | | | | +--- androidx.datastore:datastore-preferences-proto:1.1.7 (c) | | | | | \--- androidx.datastore:datastore-preferences-external-protobuf:1.1.7 (c) | | | | +--- androidx.datastore:datastore-core-okio:1.1.7 | | | | | \--- androidx.datastore:datastore-core-okio-jvm:1.1.7 | | | | | +--- androidx.datastore:datastore-core:1.1.7 (*) | | | | | +--- com.squareup.okio:okio:3.4.0 -> 3.9.1 (*) | | | | | +--- org.jetbrains.kotlin:kotlin-stdlib:1.8.22 -> 2.1.0 (*) | | | | | +--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3 -> 1.9.0 (*) | | | | | +--- androidx.datastore:datastore:1.1.7 (c) | | | | | +--- androidx.datastore:datastore-core:1.1.7 (c) | | | | | +--- androidx.datastore:datastore-preferences:1.1.7 (c) | | | | | +--- androidx.datastore:datastore-preferences-core:1.1.7 (c) | | | | | +--- androidx.datastore:datastore-preferences-proto:1.1.7 (c) | | | | | \--- androidx.datastore:datastore-preferences-external-protobuf:1.1.7 (c) | | | | +--- com.squareup.okio:okio:3.4.0 -> 3.9.1 (*) | | | | +--- org.jetbrains.kotlin:kotlin-stdlib:1.8.22 -> 2.1.0 (*) | | | | +--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3 -> 1.9.0 (*) | | | | +--- androidx.datastore:datastore-core:1.1.7 (c) | | | | +--- androidx.datastore:datastore-core-okio:1.1.7 (c) | | | | +--- androidx.datastore:datastore-preferences:1.1.7 (c) | | | | +--- androidx.datastore:datastore-preferences-core:1.1.7 (c) | | | | +--- androidx.datastore:datastore-preferences-proto:1.1.7 (c) | | | | \--- androidx.datastore:datastore-preferences-external-protobuf:1.1.7 (c) | | | +--- androidx.datastore:datastore-preferences-core:1.1.7 | | | | \--- androidx.datastore:datastore-preferences-core-android:1.1.7 | | | | +--- androidx.datastore:datastore-core:1.1.7 (*) | | | | +--- androidx.datastore:datastore-core-okio:1.1.7 (*) | | | | +--- androidx.datastore:datastore-preferences-proto:1.1.7 | | | | | +--- androidx.datastore:datastore-preferences-external-protobuf:1.1.7 | | | | | | +--- androidx.datastore:datastore:1.1.7 (c) | | | | | | +--- androidx.datastore:datastore-core:1.1.7 (c) | | | | | | +--- androidx.datastore:datastore-core-okio:1.1.7 (c) | | | | | | +--- androidx.datastore:datastore-preferences:1.1.7 (c) | | | | | | +--- androidx.datastore:datastore-preferences-core:1.1.7 (c) | | | | | | \--- androidx.datastore:datastore-preferences-proto:1.1.7 (c) | | | | | +--- androidx.datastore:datastore:1.1.7 (c) | | | | | +--- androidx.datastore:datastore-core:1.1.7 (c) | | | | | +--- androidx.datastore:datastore-core-okio:1.1.7 (c) | | | | | +--- androidx.datastore:datastore-preferences:1.1.7 (c) | | | | | +--- androidx.datastore:datastore-preferences-core:1.1.7 (c) | | | | | \--- androidx.datastore:datastore-preferences-external-protobuf:1.1.7 (c) | | | | +--- com.squareup.okio:okio:3.4.0 -> 3.9.1 (*) | | | | +--- org.jetbrains.kotlin:kotlin-stdlib:1.8.22 -> 2.1.0 (*) | | | | +--- androidx.datastore:datastore:1.1.7 (c) | | | | +--- androidx.datastore:datastore-core:1.1.7 (c) | | | | +--- androidx.datastore:datastore-core-okio:1.1.7 (c) | | | | +--- androidx.datastore:datastore-preferences:1.1.7 (c) | | | | +--- androidx.datastore:datastore-preferences-proto:1.1.7 (c) | | | | \--- androidx.datastore:datastore-preferences-external-protobuf:1.1.7 (c) | | | +--- org.jetbrains.kotlin:kotlin-stdlib:1.8.22 -> 2.1.0 (*) | | | +--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3 -> 1.9.0 (*) | | | +--- androidx.datastore:datastore:1.1.7 (c) | | | +--- androidx.datastore:datastore-core:1.1.7 (c) | | | +--- androidx.datastore:datastore-core-okio:1.1.7 (c) | | | +--- androidx.datastore:datastore-preferences-core:1.1.7 (c) | | | +--- androidx.datastore:datastore-preferences-proto:1.1.7 (c) | | | \--- androidx.datastore:datastore-preferences-external-protobuf:1.1.7 (c)

gaoxu19930112 avatar Nov 28 '25 09:11 gaoxu19930112

Thank you for that @gaoxu19930112. Looking through the dependencies you shared, it looks like you're using datastore-preferences 1.0.0, which has been upgraded to 1.1.7, and that could be because Firebase Android SDK is using 1.1.7 version. Gradle resolves dependency conflict by using the strategy "newest version wins".

Please note, it's quite difficult to investigate the issue when it's not consistently reproducible. You mentioned that the issue occurs on small number of user devices. Is there common devices and/or android versions?

lehcar09 avatar Dec 04 '25 15:12 lehcar09

Hey @gaoxu19930112. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

google-oss-bot avatar Dec 10 '25 18:12 google-oss-bot

Since there haven't been any recent updates here, I am going to close this issue.

@gaoxu19930112 if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.

google-oss-bot avatar Dec 16 '25 18:12 google-oss-bot