I always get this error when rebuild room in ios: ...
# multiplatform
h
I always get this error when rebuild room in ios:
Copy code
Task :composeApp:compileCommonMainKotlinMetadata FAILED
e: file:///Users/mohdhafiz/StudioProjects/katmaans_mobile_frontend/composeApp/src/commonMain/kotlin/com/kloudius/katmaans/data/db/AppDatabase.kt:23:8 Object 'AppDatabaseConstructor' is not abstract and does not implement abstract member 'initialize'.
sample code
Copy code
// The Room compiler generates the `actual` implementations.
@Suppress("NO_ACTUAL_FOR_EXPECT")
expect object AppDatabaseConstructor : RoomDatabaseConstructor<AppDatabase>
Event upgrade library room also the same and running ./gradlew build failed because of this. how to solve?
p
Multiplatform is a big channel and the question might fall behind quickly. Better to ask in a more specialized channel #C7KS458SJ
c
And don’t cross post to multiple channels - that’s considered spam and stops traceability for others.
h
@Pablichjenkov already but no respond
p
Most people in this forum are busy and located in different timezones. You gotta be patient. In the meantime you can try to reach the project maintainers through other means. Like GitHub issues or any other issue tracking system the project may have. Also make sure you do some research before posting a question, maybe someone already solved it in stackoverflow or similar forum
h
@Pablichjenkov I have seen the sample code room still not remove this :
Copy code
// The Room compiler generates the `actual` implementations.
@Suppress("NO_ACTUAL_FOR_EXPECT")
expect object AppDatabaseConstructor : RoomDatabaseConstructor<AppDatabase>
p
Ok, I am really not familiar with room KMP. But you can ask this question there, in the repo
c
It’s right in the docs why it’s needed
> When you declare an expect object with the interface RoomDatabaseConstructor, the Room compiler generates the actual implementations. Android Studio might issue a warning "Expected object 'AppDatabaseConstructor' has no actual declaration in module"; you can suppress the warning with @Suppress("NO_ACTUAL_FOR_EXPECT").
https://developer.android.com/kotlin/multiplatform/room#defining-database
h
what does it mean : Note that you can optionally use actual / expect declarations to create platform-specific Room implementations. For example, you can add a platform-specific DAO that is defined in common code using expect and then specify the actual definitions with additional queries in platform-specific source sets.?
e
did you setup ksp for room library?? here is a workable repo use room database CMP-bookpedia https://github.com/philipplackner/CMP-Bookpedia.git
here is key code of constructor
h
@Eric Ho after adding override fun initialize and running ./gradlew build got this following error: when i running ./gradlew build got this error:
> Task :composeApp:linkReleaseFrameworkIosArm64 FAILED
w: Cannot infer a bundle ID from packages of source files and exported dependencies, use the bundle name instead: ComposeApp. Please specify the bundle ID explicitly using the -Xbinary=bundleId=<id> compiler flag. e: Compilation failed: Java heap space * Source files: * Compiler version: 2.0.20 * Output kind: FRAMEWORK and here also:
> Task :composeApp:xcodeVersion
w: Kotlin <-> Xcode compatibility issue: The selected Xcode version (16.2) is higher than the maximum known to the Kotlin Gradle Plugin. Stability in such configuration hasn't been tested, please report encountered issues to https://kotl.in/issue Maximum tested Xcode version: 15.3