Status Update
Comments
yb...@google.com <yb...@google.com> #2
For Kotlin 2.0 and KSP 2.0 the Cannot change attributes of configuration ':composeApp:debugFrameworkIosX64' after it has been locked for mutation
really seems like a KSP issue. You should file a bug in their repository with a sample app if possible.
If you downgrade to Kotlin 1.9 then things 'should' work, there are example apps out there with such configuration, like the following one:
wo...@gmail.com <wo...@gmail.com> #3
Will try to use the example provided by you to check if it fixes the issue.
pa...@gmail.com <pa...@gmail.com> #4
Note that this issue happens when applying the Compose, KSP and Room Plugin together in Kotlin 2.0.x, the workaround for now is to not use the Room Gradle Plugin and instead specify the schema location vis KSP arguments:
// In the build.gradle
ksp {
arg("room.schemaLocation", "${projectDir}/schemas")
}
yb...@google.com <yb...@google.com> #5
Hi, I encountered a similar problem and was able to resolve it by updating the dependencies
room = "2.7.0-alpha08"
ksp = "2.0.20-1.0.25"
compose-plugin = "1.6.11"
kotlin = "2.0.20"
ya...@gmail.com <ya...@gmail.com> #6
I would like to implement this. I already started analysis and will come back with a rough design idea in a couple of days.
ya...@gmail.com <ya...@gmail.com> #7
After spending some time on analysis I created a design doc with API proposal. I described how an implementation could work as well. I've probably missed some cases so please take a look and comment.
ap...@google.com <ap...@google.com> #8
Branch: androidx-master-dev
commit 7bd7c652fdb061d643b80f09ed3a2f1da8b12e23
Author: mzgreen <yairobbe@gmail.com>
Date: Sat Sep 19 06:02:23 2020
[GH] Add Provided Type Converter feature
This change introduces a new `@ProvidedTypeConverter` annotation that gives developers control over type converter instantiation so they can use external dependencies inside type converters. A type converter class annotated with `@ProvidedTypeConverter` won't be instantiated by Room. Room will expect such converters to be passed at runtime using new `builder.addTypeConverter()` method.
Design doc:
Test: Added `ProvidedTypeConverterTest`
Fixes:
RelNote: Room can have provided type converter annotation which allow developers to take control over type converters instantiation
This is an imported pull request from
Resolves #75
Github-Pr-Head-Sha: 7977774c1e06737ef3de88b6a57f54cda1196030
GitOrigin-RevId: c9a9d960cf95ac6cb329d8509b11d992cc034350
Change-Id: Ie4fa505b36f8aa3c98091f60af9cbbdb10ca3f33
M room/common/api/current.txt
M room/common/api/public_plus_experimental_current.txt
M room/common/api/restricted_current.txt
A room/common/src/main/java/androidx/room/ProvidedTypeConverter.java
M room/compiler/src/main/kotlin/androidx/room/processor/CustomConverterProcessor.kt
M room/compiler/src/main/kotlin/androidx/room/processor/ProcessorErrors.kt
M room/compiler/src/main/kotlin/androidx/room/solver/types/CustomTypeConverterWrapper.kt
M room/compiler/src/main/kotlin/androidx/room/vo/CustomTypeConverter.kt
M room/compiler/src/main/kotlin/androidx/room/writer/ClassWriter.kt
M room/compiler/src/main/kotlin/androidx/room/writer/DaoWriter.kt
M room/compiler/src/main/kotlin/androidx/room/writer/DatabaseWriter.kt
M room/compiler/src/test/data/daoWriter/output/ComplexDao.java
M room/compiler/src/test/data/daoWriter/output/DeletionDao.java
M room/compiler/src/test/data/daoWriter/output/UpdateDao.java
M room/compiler/src/test/data/daoWriter/output/WriterDao.java
M room/compiler/src/test/data/databasewriter/output/ComplexDatabase.java
A room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/ProvidedTypeConverterTest.java
M room/runtime/api/current.txt
M room/runtime/api/public_plus_experimental_current.txt
M room/runtime/api/restricted_current.txt
M room/runtime/src/main/java/androidx/room/DatabaseConfiguration.java
M room/runtime/src/main/java/androidx/room/RoomDatabase.java
M room/testing/src/main/java/androidx/room/testing/MigrationTestHelper.java
Description
These converters of cause need an instance of moshi.
It would be great if you could let the room builder take converters so one can properly inject the converters dependencies.
Right now the "hack" that you see on many stackoverflow posts is that people use a static reference to the dagger component.
The api could look like this:
@Provides
@JvmStatic
@Singleton
fun provideAppDb(context: Context, migrations: List<@JvmSuppressWildcards Migration>, xConverter : XConverter): AppDb {
return Room.databaseBuilder(context, AppDb::class.java, "repo")
.addMigrations(*migrations.toTypedArray())
.addConverter(xConverter)
.build()
}