amplitude / Amplitude-Kotlin

Amplitude Kotlin SDK
MIT License
27 stars 10 forks source link

App crashes when userId is set: Could not create directory at /tmp/amplitude-identity #137

Closed el-fasoh closed 1 year ago

el-fasoh commented 1 year ago

Expected Behavior

Application should not crash when a user logs in and setUserId is called

Current Behavior

The app launches properly when userId is not set. When a user logs in the app crashes: Stacktrace:

  java.io.IOException: Could not create directory at /tmp/amplitude-identity/$default_instance
         at com.amplitude.id.utilities.FileUtilsKt.createDirectory(FileUtils.kt:9)
         at com.amplitude.id.FileIdentityStorage.<init>(FileIdentityStorage.kt:21)
         at com.amplitude.id.FileIdentityStorageProvider.getIdentityStorage(FileIdentityStorage.kt:71)
         at com.amplitude.core.Amplitude$build$built$1.invokeSuspend(Amplitude.kt:105)
         at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
         at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)

Possible Solution

Steps to Reproduce

  1. Invoke amplitude.setUserId(YOUR_ID)

Environment

Mercy811 commented 1 year ago

Hi @el-fasoh, we'd recommend to follow our example project to set user id. It works well on my local.

Could you give more details like environment settings if the example project still fails.

el-fasoh commented 1 year ago

Hi @Mercy811 after looking at the sample I notice there are two Amplitude classes in the SDK com.amplitude.android.Amplitude and com.amplitude.core.Amplitude. My setup was using the one from core and that was causing crashes.