Dean Djermanović
08/08/2024, 4:13 PM@ConstructedBy
and RoomDatabaseConstructor
APIs in Room 2.7.0-alpha06. Would appreciate any insights.Dmitrii Napolov
08/11/2024, 6:09 AMExpected object 'DatabaseCtor' has no actual declaration in module *
for every module that I have. I I add the implementation myself I'm getting SOF on IOS.Kirill Borichevskiy
08/11/2024, 9:00 AM2.7.0-alpha06
. All you need to do is create an expect object
for the constructor (your MusicDatabaseConstructor
) and specify it in the @ConstructedBy
annotation for the database. KSP will override and generate the initialize()
method for the platform on which you're building. In my case, I didn't specify the factory when creating the database in the Koin module because, thanks to @ConstructedBy
, the appropriate initialize()
implementation will be found.
Despite Android Studio showing "Expected object...has no actual declaration" (even if you've generated it for all the platforms you need), this doesn't prevent the project from running successfully.M Saif Ullah
08/11/2024, 2:27 PMe: file:///Users/saif-ullah/Developer/ps/Expensify/composeApp/build/generated/ksp/metadata/commonMain/kotlin/data/local/database/ExpenseDatabaseConstructor.kt:5:22 'actual object ExpenseDatabaseConstructor : RoomDatabaseConstructor<ExpenseDatabase>' has no corresponding expected declaration
e: file:///Users/saif-ullah/Developer/ps/Expensify/composeApp/build/generated/ksp/metadata/commonMain/kotlin/data/local/database/ExpenseDatabaseConstructor.kt:5:22 ExpenseDatabaseConstructor: expect and corresponding actual are declared in the same module
e: file:///Users/saif-ullah/Developer/ps/Expensify/composeApp/build/generated/ksp/metadata/commonMain/kotlin/data/local/database/ExpenseDatabaseConstructor.kt:5:22 'actual object ExpenseDatabaseConstructor : RoomDatabaseConstructor<ExpenseDatabase>' has no corresponding expected declaration
e: file:///Users/saif-ullah/Developer/ps/Expensify/composeApp/build/generated/ksp/metadata/commonMain/kotlin/data/local/database/ExpenseDatabaseConstructor.kt:5:22 Redeclaration:
actual object ExpenseDatabaseConstructor : RoomDatabaseConstructor<ExpenseDatabase>
e: file:///Users/saif-ullah/Developer/ps/Expensify/composeApp/build/generated/ksp/metadata/commonMain/kotlin/data/local/database/ExpenseDatabaseConstructor.kt:5:22 'actual object ExpenseDatabaseConstructor : RoomDatabaseConstructor<ExpenseDatabase>' has no corresponding expected declaration
e: file:///Users/saif-ullah/Developer/ps/Expensify/composeApp/build/generated/ksp/metadata/commonMain/kotlin/data/local/database/ExpenseDatabaseConstructor.kt:5:22 Redeclaration:
actual object ExpenseDatabaseConstructor : RoomDatabaseConstructor<ExpenseDatabase>
e: file:///Users/saif-ullah/Developer/ps/Expensify/composeApp/build/generated/ksp/metadata/commonMain/kotlin/data/local/database/ExpenseDatabaseConstructor.kt:5:22 'actual object ExpenseDatabaseConstructor : RoomDatabaseConstructor<ExpenseDatabase>' has no corresponding expected declaration
e: file:///Users/saif-ullah/Developer/ps/Expensify/composeApp/build/generated/ksp/metadata/commonMain/kotlin/data/local/database/ExpenseDatabaseConstructor.kt:5:22 Redeclaration:
actual object ExpenseDatabaseConstructor : RoomDatabaseConstructor<ExpenseDatabase>
e: file:///Users/saif-ullah/Developer/ps/Expensify/composeApp/build/generated/ksp/metadata/commonMain/kotlin/data/local/database/ExpenseDatabaseConstructor.kt:5:22 'actual object ExpenseDatabaseConstructor : RoomDatabaseConstructor<ExpenseDatabase>' has no corresponding expected declaration
e: file:///Users/saif-ullah/Developer/ps/Expensify/composeApp/build/generated/ksp/metadata/commonMain/kotlin/data/local/database/ExpenseDatabaseConstructor.kt:5:22 Redeclaration:
actual object ExpenseDatabaseConstructor : RoomDatabaseConstructor<ExpenseDatabase>
e: file:///Users/saif-ullah/Developer/ps/Expensify/composeApp/build/generated/ksp/metadata/commonMain/kotlin/data/local/database/ExpenseDatabaseConstructor.kt:5:22 'actual object ExpenseDatabaseConstructor : RoomDatabaseConstructor<ExpenseDatabase>' has no corresponding expected declaration
e: file:///Users/saif-ullah/Developer/ps/Expensify/composeApp/build/generated/ksp/metadata/commonMain/kotlin/data/local/database/ExpenseDatabaseConstructor.kt:5:22 Redeclaration:
actual object ExpenseDatabaseConstructor : RoomDatabaseConstructor<ExpenseDatabase>
Dean Djermanović
08/11/2024, 5:10 PMdependencies {
add("kspAndroid", libs.androidx.room.compiler)
// ...
}
Nothing changed—still the same error. However, after closing the project, deleting the .idea
folder from the root of the project, and reopening it, I finally got it to work on Android.
That said, it’s still not generating anything for desktop or iOS, and I haven’t figured out why yet.Kirill Borichevskiy
08/11/2024, 6:10 PMDean Djermanović
08/12/2024, 7:21 AMExpected DatabaseConstructor has no actual declaration in module
error. It seems like some KSP config might be missing for those targets. Could you share your build.gradle
file?Ewela
08/12/2024, 7:24 AMdependencies {
ksp(libs.room.compiler)
add("kspAndroid",libs.room.compiler)
add("kspIosSimulatorArm64",libs.room.compiler)
add("kspIosX64",libs.room.compiler)
add("kspIosArm64",libs.room.compiler)
}
and its building for ios nowaris
08/12/2024, 7:31 AMaris
08/12/2024, 7:32 AMaris
08/12/2024, 7:33 AMDean Djermanović
08/12/2024, 8:37 AMadd("kspDesktop", libs.androidx.room.compiler)
However, when I try to do similar for iOS:
add("kspIosX64", libs.androidx.room.compiler)
add("kspIosArm64", libs.androidx.room.compiler)
add("kspIosSimulatorArm64", libs.androidx.room.compiler)
I get this error:
Cannot change attributes of configuration ':composeApp:debugFrameworkIosX64' after it has been locked for mutation.
danysantiago
08/12/2024, 8:45 PMCannot change attributes of configuration
is due to the combination of the Compose and Room plugin being used together, a workaround is described in https://issuetracker.google.com/343408758#comment4Dean Djermanović
08/13/2024, 7:17 AM1.7.0-alpha01
• KSP plugin: 2.0.10-1.0.24
• Kotlin: 2.0.10
danysantiago
08/13/2024, 12:38 PMCannot change attributes of configuration
by removing the Room Gradle but I am using Compose Plugin version 1.6.11
. But with 1.7.0-alpha01
the problem is back, then I think the issue must be KSP + Compose Plugin. We'll need to file a bug to one of those two plugin owners.Phil Bayfield
08/15/2024, 7:32 AMdependencies {
add("kspAndroid", libs.androidx.room.compiler)
add("kspIosX64", libs.androidx.room.compiler)
add("kspIosArm64", libs.androidx.room.compiler)
add("kspIosSimulatorArm64", libs.androidx.room.compiler)
}
Meet
09/12/2024, 12:20 PMksp = "2.0.20-1.0.24"
androidx-room = "2.7.0-alpha07"
danysantiago
09/12/2024, 2:17 PMUmesh Gupta
09/13/2024, 9:24 AMMeet
09/14/2024, 3:03 PM