Pablo
01/17/2025, 11:47 AMapp.preferences_pb.tmp
file is created on the application AppData folder, where it haves permissions and reading or writting of other non datastore files works... but in this case this file has 0 bytes size. Note it's a .tmp
file, and when I execute it under Android Studio
I receive a full working file without .tmp
extension. What is happening? I'm adding how I use datastore in the thread.Pablo
01/17/2025, 11:48 AMclass DataStoreUseCase() {
private val dataStore = createDataStore()
suspend fun saveString(key: DataStoreKey, value: String) {
dataStore.edit { preferences ->
preferences[stringPreferencesKey(key.name)] = value
}
}
suspend fun getString(key: DataStoreKey): String? {
val preferences = dataStore.data.first()
return preferences[stringPreferencesKey(key.name)]
}
private fun createDataStore(): DataStore<Preferences> =
PreferenceDataStoreFactory.createWithPath(
produceFile = { "app.preferences_pb".toPath() }
)
}
Chrimaeon
01/17/2025, 4:51 PMPablo
01/17/2025, 6:06 PMPablo
01/17/2025, 6:06 PMPablo
01/17/2025, 6:07 PMnativeDistributions{
targetFormats(TargetFormat.Msi)
modules("jdk.unsupported")
modules("jdk.unsupported.desktop")
}
those two last "modules" lines make it work, I hope they will solve this, sounds very bad to use these lines with the word "unsupported"Pablo
01/17/2025, 6:09 PMPablo
01/17/2025, 6:13 PMChrimaeon
01/17/2025, 6:25 PMChrimaeon
01/17/2025, 6:25 PMPablo
01/17/2025, 6:28 PMPablo
01/17/2025, 6:28 PMPablo
01/17/2025, 6:28 PMChrimaeon
01/17/2025, 6:33 PMPablo
01/17/2025, 6:55 PMPablo
01/17/2025, 6:56 PMPablo
01/17/2025, 6:57 PMazabost
01/17/2025, 10:36 PMthose two lines make it workCan you clarify which lines you added exactly? Did you mean these?
modules("jdk.unsupported")
modules("jdk.unsupported.desktop")
Pablo
01/17/2025, 10:41 PMMichael Paus
01/18/2025, 8:53 AMmodules("java.instrument", "jdk.unsupported", "java.sql")
As you can see I also have to use “jdk.unsupported”. There is a Gradle task “`suggestModules`” to help you with this but it also does not always work. So, it often is a try and error game. See: https://www.jetbrains.com/help/kotlin-multiplatform-dev/compose-native-distribution.html#including-jdk-modules