Status Update
Comments
da...@google.com <da...@google.com> #2
This is a particularly hard device to come by - do you happen to have access to the device? If so could you provide us with the output of: adb shell dumpsys media.camera > info.txt
Thanks!
ei...@gmail.com <ei...@gmail.com> #3
Stacktrace:
Caused by: java.lang.IllegalArgumentException: Can not get supported output size under supported maximum for the format: 34
at androidx.camera.camera2.internal.SupportedSurfaceCombination.getSupportedOutputSizes(SupportedSurfaceCombination.java:355)
at androidx.camera.camera2.internal.SupportedSurfaceCombination.getSuggestedResolutions(SupportedSurfaceCombination.java:197)
at androidx.camera.camera2.internal.Camera2DeviceSurfaceManager.getSuggestedResolutions(Camera2DeviceSurfaceManager.java:198)
at androidx.camera.core.CameraX.calculateSuggestedResolutions(CameraX.java:943)
at androidx.camera.core.CameraX.bindToLifecycle(CameraX.java:293)
at androidx.camera.lifecycle.ProcessCameraProvider.bindToLifecycle(ProcessCameraProvider.java:227)
Below are some findings based on our debugging
When Dex is connected
previewConfig.getMaxResolution() is returning "731x411" as maxSize.
Inside Preview.Builder.build() -> Default_MAX_resolution is set to "CameraX.getSurfaceManager().getPreviewSize()" which is 731x411
this is being picked as maxSize.
While rendering maxSize is 731x411 and minSize is 640x480 and below are available outputSizes
0 = {Size@11860} "4032x3024"
1 = {Size@11861} "3984x2988"
2 = {Size@11862} "4032x2268"
3 = {Size@11863} "3024x3024"
4 = {Size@11864} "2976x2976"
5 = {Size@11865} "3840x2160"
6 = {Size@11866} "3264x2448"
7 = {Size@11867} "4032x1960"
8 = {Size@11868} "2880x2160"
9 = {Size@11869} "3264x1836"
10 = {Size@11870} "2160x2160"
11 = {Size@11871} "2560x1440"
12 = {Size@11872} "2224x1080"
13 = {Size@11873} "2048x1152"
14 = {Size@11874} "1920x1080"
15 = {Size@11875} "1440x1080"
16 = {Size@11876} "1088x1088"
17 = {Size@11877} "1280x720"
18 = {Size@11878} "1024x768"
19 = {Size@11879} "1056x704"
20 = {Size@11880} "960x720"
21 = {Size@11881} "960x540"
22 = {Size@11882} "720x720"
23 = {Size@11883} "800x450"
24 = {Size@11884} "720x480"
25 = {Size@11885} "640x480"
26 = {Size@11886} "352x288"
27 = {Size@11887} "320x240"
28 = {Size@11888} "256x144"
29 = {Size@11889} "176x144"
and couldn't find any size in this range.
When Dex not connected
minsize = 640x480
maxsize = 1920x1080
0 = {Size@11836} "4032x3024"
1 = {Size@11837} "3984x2988"
2 = {Size@11838} "4032x2268"
3 = {Size@11839} "3024x3024"
4 = {Size@11840} "2976x2976"
5 = {Size@11841} "3840x2160"
6 = {Size@11842} "3264x2448"
7 = {Size@11843} "4032x1960"
8 = {Size@11844} "2880x2160"
9 = {Size@11845} "3264x1836"
10 = {Size@11846} "2160x2160"
11 = {Size@11847} "2560x1440"
12 = {Size@11848} "2224x1080"
13 = {Size@11849} "2048x1152"
14 = {Size@11850} "1920x1080"
15 = {Size@11851} "1440x1080"
16 = {Size@11852} "1088x1088"
17 = {Size@11853} "1280x720"
18 = {Size@11854} "1024x768"
19 = {Size@11855} "1056x704"
20 = {Size@11856} "960x720"
21 = {Size@11857} "960x540"
22 = {Size@11858} "720x720"
23 = {Size@11859} "800x450"
24 = {Size@11860} "720x480"
25 = {Size@11861} "640x480"
26 = {Size@11862} "352x288"
27 = {Size@11863} "320x240"
28 = {Size@11864} "256x144"
29 = {Size@11865} "176x144"
and we have 12 available sizes in this range
Camera2DeviceSurfaceManager.java:: getPreviewSize()
mCameraSupportedSurfaceCombinationMap.get(cameraId).getSurfaceDefinition().getPreviewSize() = "1920x1080"
cameraId=0
da...@gmail.com <da...@gmail.com> #4
The issue root cause is that CameraX will default filter out sizes smaller than 640x480. For Preview, the max size will be limited to under display size. I checked the HW spec info for the issue related devices. Display size of FUJITSU F-04J/F-05J is 360x640. That will result int that no size exists in the conditions that is larger or equal to 640x480 and smaller or equal to 360x640.
A temporary workaround for this situation is to use Preview.Builder#setTargetResolution() to set a size smaller than 640x480 to bypass the problem.
For device FUJITSU arrowsM04, I checked its HW spec info and its display size I found is 1280x720. It seems that the problem should not exist in the device.
Could you confirm that the problem exist on arrowsM04 device? What will be the returned value when using Display#getRealSize to obtain the display size?
ja...@gmail.com <ja...@gmail.com> #5
> A temporary workaround for this situation is to use Preview.Builder#setTargetResolution() to set a size smaller than 640x480 to bypass the problem.
OK. I will try it.
> Could you confirm that the problem exist on arrowsM04 device?
We receive the crash report (Crashlytics) that this crash has occurred on arrowsM04.
We don't have this device so we can't confirm that the problem really exist on arrowsM04.
> What will be the returned value when using Display#getRealSize to obtain the display size?
We can't investigate it for the same reason.
Thank you.
da...@google.com <da...@google.com> #6
This issue happened on devices that the display size is smaller than 640x480. In original auto-resolution mechanism, supported sizes smaller than 640x480 will be default filter out.
The auto-resolution mechanism encodes the guaranteed configurations tables in CameraDevice#createCaptureSession(SessionConfiguration). It defines that the PREVIEW size is the small one of the device display size and 1080p. The PREVIEW size will be the maximal size limitation for Preview use case. The reason it limits the size to display size and 1080p is the stream output in display size or 1080p has been able to provide good enough preview quality. Therefore, auto-resolution mechanism will limit the selected size to be smaller than the small one of the device display size and 1080p.
With above two conditions, in this issue, all sizes smaller than 640x480 have been filter out, therefore, there is no size smaller than the display size 320x240 can be selected to use. And cause the exception.
Solution:
When the display size is smaller than 640x480, auto-resolution mechanism won't filter out those small sizes smaller than 640x480. This makes those small size be left and can be selected for the Preview use case on small display devices.
The solution has been merged and will be included in next CameraX release.
ra...@gmail.com <ra...@gmail.com> #7
Hello.
This crash still occurs.
- CAMERAX VERSION: 1.0.0-beta4
- ANDROID OS BUILD NUMBER: Android 7.1.1
- DEVICE NAME: FUJITSU F-02H
We receive following crash report from FUJITSU F-02H. So far We have received this crash report only from F-02H.
java.lang.IllegalArgumentException
Can not get supported output size under supported maximum for the format: 34
androidx.camera.camera2.internal.SupportedSurfaceCombination.getSupportedOutputSizes (SupportedSurfaceCombination.java:349)
androidx.camera.camera2.internal.SupportedSurfaceCombination.getSuggestedResolutions (SupportedSurfaceCombination.java:197)
androidx.camera.camera2.internal.Camera2DeviceSurfaceManager.getSuggestedResolutions (Camera2DeviceSurfaceManager.java:198)
androidx.camera.core.CameraX.calculateSuggestedResolutions (CameraX.java:949)
androidx.camera.core.CameraX.bindToLifecycle (CameraX.java:351)
androidx.camera.lifecycle.ProcessCameraProvider.bindToLifecycle (ProcessCameraProvider.java:230)
(our application's package name).CameraFragment.bindCameraUseCases (CameraFragment.java:174)
ei...@gmail.com <ei...@gmail.com> #8
Could you help to provide the following information to clarify the issue?
1. Is the full name of the device Fujitsu Arrows NX F-02H that has a 1440x2560 display?
2. Please help to provide the supported output sizes of ImageFormat.PRIVATE that is obtained by StreamConfigurationMap#getOutputSizes(int).
sa...@softwarejourneys.co <sa...@softwarejourneys.co> #9
- Is the full name of the device Fujitsu Arrows NX F-02H that has a 1440x2560 display?
Yes
- Please help to provide the supported output sizes of ImageFormat.PRIVATE that is obtained by StreamConfigurationMap#getOutputSizes(int).
Since we don't have this device, we'll try to collect this information in the next version of our app. The next version will be released later this month.
ya...@gmail.com <ya...@gmail.com> #10
Hello.
- Please help to provide the supported output sizes of ImageFormat.PRIVATE that is obtained by StreamConfigurationMap#getOutputSizes(int).
We have collected the output of the device where the crash occurs.
Device1
- Model : arrows Be F-05J
- Android Version : 7.1.1
- Supported output sizes of ImageFormat.PRIVATE
CameraId 0: 480x480
CameraId 1: 2048x1536 ,1920x1080 ,1280x720 ,960x720 ,640x480 ,320x240 ,176x144
Device2
- Model : Fujitsu arrows M04
- Android Version : 7.1.1
- Supported output sizes of ImageFormat.PRIVATE
CameraId 0: 480x480
CameraId 1: 2048x1536 ,1920x1080 ,1280x720 ,960x720 ,640x480 ,320x240 ,176x144
Additional Information
CameraX version : 1.0.0-beta04
We collect the supported output sizes by following code.
val errorString = buildString {
append("The supported output sizes of ImageFormat.PRIVATE: ")
(requireContext().getSystemService(Context.CAMERA_SERVICE) as CameraManager).apply {
cameraIdList.forEachIndexed { index, cameraId ->
val msg = if (VERSION.SDK_INT >= VERSION_CODES.M) {
val configurationMap =
getCameraCharacteristics(cameraId).get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP)
val sizes = configurationMap?.getOutputSizes(ImageFormat.PRIVATE)
"CameraId $index: ${sizes?.joinToString(" ,")}"
} else {
"CameraId $index: This device version is under M."
}
append(msg)
}
}
}
ro...@gmail.com <ro...@gmail.com> #11
da...@google.com <da...@google.com> #12
I tried to find the device specs and both 720x1280
size display. For the camera id 0 device, it is a different case that the display size is larger than 640x480
but the device only supports a 480x480
size. The case also caused the same IllegalArgumentException and was also fixed by 1.0.0-beta04
release. Before 480x480
size would be filtered out and then caused the IllegalArgumentException. After it was merged, the 640x480
size threshold was removed and then the 480x480
size would be kept and selected to use.
It looks like 1.0.0-beta04
release had been used to collect the supported sizes information. But the issue should have been fixed by 1.0.0-beta04
release. Did you only check the device model name to collect the supported sizes information or collect the information when the IllegalArgumentException issue happens again?
CameraX's 1.0.0-beta04
version. Maybe you can also consider to upgrade to the latest 1.0.0-rc01
version for your application. Thanks.
da...@google.com <da...@google.com> #13
Did you only check the device model name to collect the supported sizes information or collect the information when the IllegalArgumentException issue happens again?
We collect informations only from the device on which IllegalArgumentException happened.
Our latest app uses CameraX version 1.0.0-beta10
and this issue still occurres.
However we don't receive crash report from Fujitsu arrows Be F-05J
or Fujitsu arrows M04
so far. (This doesn't mean this issue is fixed on these devices because our app is heavily rely on camera so these device's user wouldn't use our app anymore.)
Instead, we receive crash report from
- Model : Fujitsu F-03K
- Android Version : 7.1.2
- Supported output sizes of ImageFormat.PRIVATE
CameraId 0 : 480x480
CameraId 1 : 2048x1536 ,1920x1080 ,1280x720 ,960x720 ,640x480 ,320x240 ,176x144
ro...@gmail.com <ro...@gmail.com> #14
I missed some settings when I simulated the issue by robolectric test so that I was not able to reproduce it. Now, I can reproduce the issue if the device only supports one 480x480 resolution. I'm working on the solution and target to make it included in next release.
ap...@google.com <ap...@google.com> #15
Branch: androidx-main
commit 69d15dff7bb857ee33a0f643ff42a0f8bc475ab2
Author: charcoalchen <charcoalchen@google.com>
Date: Fri Jan 08 18:30:03 2021
Fixed IllegalArgumentException issue happened when all preview supported sizes are smaller than 640x480 and display size is larger than 640x480.
Do not filter out sizes smaller than 640x480 when all preview supported sizes are smaller than 640x480 and display size is larger than 640x480.
Relnote:"Fixed IllegalArgumentException issue happened when all preview supported sizes are smaller than 640x480 and display size is larger than 640x480."
Bug: 150506192
Test: SupportedSurfaceCombinationTest
Change-Id: I2a63ce8e2ad42a9cc060c8635ac3603bf440b1ec
M camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/SupportedSurfaceCombination.java
M camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/SupportedSurfaceCombinationTest.java
da...@google.com <da...@google.com> #16
ma...@gmail.com <ma...@gmail.com> #17
It should be noted the the actual implementations of the RoomDatabaseConstructor expects will be generated by KSP. Warnings/errors can be ignored, at least until after you do a rebuild.
The 3rd step is specifically for the ios (or apple) side of things, no changes are needed for the android equivalent.
And I ran into build cache/ksp issues and had to do a full clean/rebuild.
an...@gmail.com <an...@gmail.com> #18
Hi! I'm still waiting for a quick solution to the problems generated in iOS
This is my data:
kotlin = "2.0.0" room = "2.7.0-alpha06" ksp = "2.0.0-1.0.21" sqlite = "2.5.0-SNAPSHOT"
import com.google.devtools.ksp.gradle.KspTaskMetadata import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi import org.jetbrains.kotlin.gradle.dsl.JvmTarget
plugins { alias(libs.plugins.kotlinMultiplatform) alias(libs.plugins.androidApplication) alias(libs.plugins.jetbrainsCompose) alias(libs.plugins.compose.compiler) alias(libs.plugins.kotlin.serialization) alias(libs.plugins.ksp) alias(libs.plugins.room) }
kotlin { androidTarget { @OptIn(ExperimentalKotlinGradlePluginApi::class) compilerOptions { jvmTarget.set(JvmTarget.JVM_11) } } listOf( iosX64(), iosArm64(), iosSimulatorArm64() ).forEach { iosTarget -> iosTarget.binaries.framework { baseName = "ComposeApp" isStatic = true linkerOpts.add("-lsqlite3") } }
sourceSets {
androidMain.dependencies {
implementation(compose.preview)
implementation(libs.androidx.activity.compose)
implementation(libs.core.splashscreen)
implementation(libs.ktor.client.okhttp)
implementation(libs.koin.android)
implementation(libs.koin.androidx.compose)
implementation(libs.xml.util.core.android)
implementation(libs.room.runtime.android)
}
commonMain.dependencies {
implementation(compose.runtime)
implementation(compose.foundation)
implementation(compose.material)
implementation(compose.ui)
implementation(compose.components.resources)
implementation(compose.components.uiToolingPreview)
implementation(libs.bundles.ktor)
api(libs.datastore.preferences)
api(libs.datastore)
api(libs.koin.core)
implementation(libs.koin.compose)
implementation(libs.koin.compose.viewmodel)
implementation(libs.lifecycle.viewmodel)
implementation(libs.navigation.compose)
implementation(libs.xml.util.core)
implementation(libs.xml.util.serialization)
implementation(libs.room.runtime)
implementation(libs.sqlite.bundled)
}
nativeMain.dependencies {
implementation(libs.ktor.client.darwin)
}
sourceSets.commonMain {
kotlin.srcDir("build/generated/ksp/metadata")
}
}
}
android { namespace = "com.itlab.match_academico" compileSdk = libs.versions.android.compileSdk.get().toInt()
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
sourceSets["main"].res.srcDirs("src/androidMain/res")
sourceSets["main"].resources.srcDirs("src/commonMain/resources")
defaultConfig {
applicationId = "com.itlab.match_academico"
minSdk = libs.versions.android.minSdk.get().toInt()
targetSdk = libs.versions.android.targetSdk.get().toInt()
versionCode = 1
versionName = "1.0"
}
packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
buildTypes {
getByName("release") {
isMinifyEnabled = false
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
buildFeatures {
compose = true
}
dependencies {
debugImplementation(compose.uiTooling)
}
}
room { schemaDirectory("$projectDir/schemas") }
dependencies { add("kspCommonMainMetadata", libs.room.compiler) add("kspAndroid", libs.room.compiler) afterEvaluate { add("kspIosSimulatorArm64", libs.room.compiler) add("kspIosX64", libs.room.compiler) add("kspIosArm64", libs.room.compiler) } }
kotlin.sourceSets.commonMain { tasks.withType<KspTaskMetadata> { kotlin.srcDir(destinationDirectory) } }
My db:
package features.configIni.data.database
import androidx.room.ConstructedBy import androidx.room.Database import androidx.room.RoomDatabase import androidx.room.RoomDatabaseConstructor
@Database( entities = [ WebServiceRoom::class ], version = 1 ) @ConstructedBy(WebServiceDatabaseConstructor::class) abstract class WebServiceDatabase: RoomDatabase() { abstract fun webserviceDao(): WebServiceDao }
expect object WebServiceDatabaseConstructor : RoomDatabaseConstructor<WebServiceDatabase>
const val DATABASE_NAME = "webService.db"
On Android, everything works fine but on iOS I get the error:
Expected WebServiceDatabaseConstructor has no actual declaration in module
when according to the official doc it does not require me to set the actual declaration
ya...@gmail.com <ya...@gmail.com> #19
I was able to build both Android/iOS with room = "2.7.0-alpha06".
I had to change composeApp/build.gradle.kts.
Solution
// libs.versions.toml
[versions]
kotlin = "2.0.10"
roomVersion = "2.7.0-alpha06"
sqlite = "2.5.0-alpha06"
ksp = "2.0.0-1.0.21"
[libraries]
androidx-room-compiler = { module = "androidx.room:room-compiler", version.ref = "roomVersion" }
androidx-room-runtime = { module = "androidx.room:room-runtime", version.ref = "roomVersion" }
sqlite-bundled = { module = "androidx.sqlite:sqlite-bundled", version.ref = "sqlite" }
[plugins]
room = { id = "androidx.room", version.ref = "roomVersion" }
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
// composeApp/build.gradle.kts
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import java.util.Properties
plugins {
...
// room
alias(libs.plugins.ksp)
alias(libs.plugins.room)
}
kotlin {
...
sourceSets {
...
iosMain {
// To provide RoomDatabaseConstructor actual declaration
kotlin.srcDir("build/generated/ksp/metadata")
dependencies {
...
}
}
}
}
dependencies {
...
// Room
add("kspCommonMainMetadata", libs.androidx.room.compiler)
add("kspAndroid", libs.androidx.room.compiler)
}
room {
schemaDirectory("$projectDir/schemas")
}
Create the following classes according to the official documentation.
- shared/src/commonMain/kotlin/Database.kt
- shared/src/androidMain/kotlin/Database.kt
- shared/src/iosMain/kotlin/Database.kt
Build
- Android Studio > Build > Clean Project
- Android Studio > Build > Rebuild Project
vi...@gmail.com <vi...@gmail.com> #20
#libs.version.toml
...
ksp = "2.0.0-1.0.21" # "1.9.23-1.0.19"
androidx-room = "2.7.0-alpha06" #2.7.0-alpha04" #"2.7.0-alpha01"
...
#shared/build.gradle.kts
plugins {
...
alias(libs.plugins.ksp)
alias(libs.plugins.room)
...
}
kotlin {
...
sourceSets {
...
iosMain {
kotlin.srcDir("build/generated/ksp/metadata")
dependencies {
...
}
}
}
}
dependencies {
// "kspAndroid"(libs.androidx.room.compiler) // For AndroidUnitTest
// "kspCommonMainMetadata"(libs.androidx.room.compiler)
add("kspCommonMainMetadata", libs.androidx.room.compiler)
add("kspAndroid", libs.androidx.room.compiler)
add("kspIosSimulatorArm64", libs.androidx.room.compiler)
add("kspIosX64", libs.androidx.room.compiler)
add("kspIosArm64", libs.androidx.room.compiler)
}
#ZDCKeyCoreDatabase.kt
@Database(entities = [UserEntity::class], version = KMPConstants.DATABASE_VERSION, exportSchema = true)
@ConstructedBy(ZDCKeyCoreDatabaseConstructor::class)
abstract class ZDCKeyCoreDatabase : RoomDatabase() {
abstract fun getUserDao(): UserDao
}
@Suppress("EXPECT_ACTUAL_CLASSIFIERS_ARE_IN_BETA_WARNING")
expect object ZDCKeyCoreDatabaseConstructor: RoomDatabaseConstructor<ZDCKeyCoreDatabase>
But the build is getting failed with below error.
e:file:///Users/..../kmp_project/zdckey_core/build/generated/ksp/metadata/commonMain/kotlin/com/..../zdckey_core/data/database/ZDCKeyCoreDatabaseConstructor.kt:5:22 'actual object ZDCKeyCoreDatabaseConstructor : RoomDatabaseConstructor<ZDCKeyCoreDatabase>' has no corresponding expected declaration
e:file:///Users/..../kmp_project/zdckey_core/build/generated/ksp/metadata/commonMain/kotlin/com/..../zdckey_core/data/database/ZDCKeyCoreDatabaseConstructor.kt:5:22 ZDCKeyCoreDatabaseConstructor: expect and corresponding actual are declared in the same module.
e: file:///Users/..../kmp_project/zdckey_core/src/commonMain/kotlin/com/..../zdckey_core/data/database/ZDCKeyCoreDatabase.kt:23:8 Object 'ZDCKeyCoreDatabaseConstructor' is not abstract and does not implement abstract member 'initialize'.
e:file:///Users/..../kmp_project/zdckey_core/src/commonMain/kotlin/com/..../zdckey_core/data/database/ZDCKeyCoreDatabase.kt:23:15 ZDCKeyCoreDatabaseConstructor: expect and corresponding actual are declared in the same module
Suggestions to solve this issue would be highly appreciated. Thanks in advance.
da...@google.com <da...@google.com> #21
Since this have changed a between alpha05 and alpha06 (and alpha07), please double check your build Gradle file configuration.
- Please apply it to all your 'end' targets (this list is exhaustive but only use the ones relevant to your project):
dependencies {
// Android
add("kspAndroid", libs.androidx.room.compiler)
// JVM (Desktop)
add("kspJvm", libs.androidx.room.compiler)
// Linux
add("kspLinuxX64", libs.androidx.room.compiler)
add("kspLinuxArm64", libs.androidx.room.compiler)
// Mac
add("kspMacosX64", libs.androidx.room.compiler)
add("kspMacosArm64", libs.androidx.room.compiler)
// iOS
add("kspIosSimulatorArm64", libs.androidx.room.compiler)
add("kspIosX64", libs.androidx.room.compiler)
add("kspIosArm64", libs.androidx.room.compiler)
}
Note that applying the processor to the kspCommonMainMetadata
should not be needed.
- Do not manually add KSP generated sources from other targets:
// DO NOT DO THIS
iosMain {
kotlin.srcDir("build/generated/ksp/metadata")
}
This just leads to errors due to the differences of generated code between the platforms, which is why its important that on step 1 the Room KSP processor is applied to all targets that will use the common sources set where the @Database
is defined.
- Do not declare explicit task dependencies:
// DO NOT DO THIS
kotlin.sourceSets.commonMain {
tasks.withType<KspTaskMetadata> {
kotlin.srcDir(destinationDirectory)
}
}
Declaring direct dependencies and adding generated sources by KSP is a red flag, these where workarounds from alpha05 that shouldn't be needed with the newer @ConstructedBy
strategy in alpha06.
- Do not create the
actual
of theexpect object
class that implementedRoomDatabaseConstructor
// shared/src/commonMain/kotlin/Database.kt
expect object MyDatabaseCtor: RoomDatabaseConstructor<MyDatabaseCtor> {
fun initialize(): MyDatabaseCtor
}
// shared/src/nativeMain/kotlin/Database.kt
// DO NOT DO THIS
actual object MyDatabaseCtor: RoomDatabaseConstructor<MyDatabaseCtor> {
fun initialize(): MyDatabaseCtor { ... }
}
-
Make sure Kotlin version matches KSP version, i.e. if using Kotlin 2.0.10 then use KSP 2.0.10-1.0.24
-
If using Kotlin 2.x then the
kotlin.native.disableCompilerDaemon = true
is not needed and can lead to another issue (https://youtrack.jetbrains.com/issue/KT-69523 ). -
If you are using the Compose Gradle Plugin and Room Gradle Plugin along with Kotlin 2.0 then you might see a separate issue regarding the plugins along the lines of
Cannot change attributes of configuration ':<project>:debugFrameworkIosX64' after it has been locked for mutation
, the workaround is to remove the Room Gradle Plugin and configure the schema directory via KSP arguments, seehttps://issuetracker.google.com/343408758 -
If you had the workaround for
clearAllTables()
, please remove it, it is no needed since Room is being applied to 'end' targets.
Feel free to comment even if the steps mentioned here don't work for you.
vi...@gmail.com <vi...@gmail.com> #22
Thanks a lot for the quick response and clarifying all the confusions.
All the mentioned checklist are verified. But the build fails with the following error.
e:file:///Users/..../kmp_project/zdckey_core/src/commonMain/kotlin/com/..../zdckey_core/data/database/ZDCKeyCoreDatabase.kt:22:8 Object 'ZDCKeyCoreDatabaseConstructor' is not abstract and does not implement abstract member 'initialize'.
#ZDCKeyCoreDatabase.kt
@Database(entities = [UserEntity::class], version = KMPConstants.DATABASE_VERSION, exportSchema = true)
@ConstructedBy(ZDCKeyCoreDatabaseConstructor::class)
abstract class ZDCKeyCoreDatabase : RoomDatabase() {
abstract fun getUserDao(): UserDao
}
expect object ZDCKeyCoreDatabaseConstructor: RoomDatabaseConstructor<ZDCKeyCoreDatabase>
Kindly share us the solution. Thanks in advance..
an...@gmail.com <an...@gmail.com> #23
I just followed the suggestions of
null cannot be cast to non-null type org.jetbrains.kotlin.load.java.structure.impl.JavaClassImpl
These are my classes
@Database( entities = [ WebServiceRoom::class ], version = 1 ) @ConstructedBy(WebServiceDatabaseConstructor::class) abstract class WebServiceDatabase: RoomDatabase() { abstract fun webserviceDao(): WebServiceDao }
expect object WebServiceDatabaseConstructor : RoomDatabaseConstructor<WebServiceDatabase>
const val DATABASE_NAME = "webService.db"
Ios: fun getWebServicesDatabase(): RoomDatabase.Builder<WebServiceDatabase>{ val dbFilePath = documentDirectory() + "/$DATABASE_NAME" return Room.databaseBuilder<WebServiceDatabase>( name = dbFilePath, ) }
@OptIn(ExperimentalForeignApi::class) private fun documentDirectory(): String { val documentDirectory = NSFileManager.defaultManager.URLForDirectory( directory = NSDocumentDirectory, inDomain = NSUserDomainMask, appropriateForURL = null, create = false, error = null, ) return requireNotNull(documentDirectory?.path) }
import database.getWebServicesDatabase import features.configIni.data.datasource.ConfigIniService import io.ktor.client.engine.darwin.Darwin import networking.createHttpClient import org.koin.dsl.module
actual val platformModule = module { single { createHttpClient(Darwin.create()) } single { ConfigIniService(get()) } single { getWebServicesDatabase() } }
Gradle: import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi import org.jetbrains.kotlin.gradle.dsl.JvmTarget
plugins { alias(libs.plugins.kotlinMultiplatform) alias(libs.plugins.androidApplication) alias(libs.plugins.jetbrainsCompose) alias(libs.plugins.compose.compiler) alias(libs.plugins.kotlin.serialization) alias(libs.plugins.ksp) alias(libs.plugins.room) }
kotlin { androidTarget { @OptIn(ExperimentalKotlinGradlePluginApi::class) compilerOptions { jvmTarget.set(JvmTarget.JVM_11) } } listOf( iosX64(), iosArm64(), iosSimulatorArm64() ).forEach { iosTarget -> iosTarget.binaries.framework { baseName = "ComposeApp" isStatic = true linkerOpts.add("-lsqlite3") } }
sourceSets {
androidMain.dependencies {
implementation(compose.preview)
implementation(libs.androidx.activity.compose)
implementation(libs.core.splashscreen)
implementation(libs.ktor.client.okhttp)
implementation(libs.koin.android)
implementation(libs.koin.androidx.compose)
implementation(libs.xml.util.core.android)
implementation(libs.room.runtime.android)
}
commonMain.dependencies {
implementation(compose.runtime)
implementation(compose.foundation)
implementation(compose.material)
implementation(compose.ui)
implementation(compose.components.resources)
implementation(compose.components.uiToolingPreview)
implementation(libs.bundles.ktor)
api(libs.datastore.preferences)
api(libs.datastore)
api(libs.koin.core)
implementation(libs.koin.compose)
implementation(libs.koin.compose.viewmodel)
implementation(libs.lifecycle.viewmodel)
implementation(libs.navigation.compose)
implementation(libs.xml.util.core)
implementation(libs.xml.util.serialization)
implementation(libs.room.runtime)
implementation(libs.sqlite.bundled)
}
iosMain {
dependencies{
implementation(libs.ktor.client.darwin)
}
}
}
}
android { namespace = "com.itlab.match_academico" compileSdk = libs.versions.android.compileSdk.get().toInt()
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
sourceSets["main"].res.srcDirs("src/androidMain/res")
sourceSets["main"].resources.srcDirs("src/commonMain/resources")
defaultConfig {
applicationId = "com.itlab.match_academico"
minSdk = libs.versions.android.minSdk.get().toInt()
targetSdk = libs.versions.android.targetSdk.get().toInt()
versionCode = 1
versionName = "1.0"
}
packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
buildTypes {
getByName("release") {
isMinifyEnabled = false
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
buildFeatures {
compose = true
}
dependencies {
debugImplementation(compose.uiTooling)
}
}
room { schemaDirectory("$projectDir/schemas") }
dependencies { // Android add("kspAndroid", libs.room.compiler) // iOS add("kspIosSimulatorArm64", libs.room.compiler) add("kspIosX64", libs.room.compiler) add("kspIosArm64", libs.room.compiler) }
kotlin = "2.0.10" room = "2.7.0-alpha06" ksp = "2.0.0-1.0.21" sqlite = "2.5.0-SNAPSHOT"
kotlin.code.style=official
#Gradle org.gradle.jvmargs=-Xmx2048M -Dfile.encoding=UTF-8 -Dkotlin.daemon.jvm.options="-Xmx2048M"
#Android android.nonTransitiveRClass=true android.useAndroidX=true
#Kotlin Multiplatform kotlin.mpp.enableCInteropCommonization=true
#Room kotlin.native.disableCompilerDaemon = true ksp.useKSP2=true
da...@google.com <da...@google.com> #24
If you are using Kotlin 2.0.10
please make sure you use matching KSP version 2.0.10-1.0.24
If you encounter an error with Cannot change attributes of configuration ':<project>:debugFrameworkIosX64' ...
then please see the workaround in
da...@google.com <da...@google.com> #25
Another important thing is that kotlin.native.disableCompilerDaemon = true
is not needed when using Kotlin 2.0.10, having it enable will lead to a different issue:
an...@gmail.com <an...@gmail.com> #26
Thank you very much for the prompt response, I really appreciate it!
I corrected your observations and I still have the same error in iOS Xcode,these are the logs I receive when I do the clean rebuild. I attached two images for a better look. Thanks for the support.
ma...@gmail.com <ma...@gmail.com> #27
Thanks! These steps helped me fix Android and iOS. JVM is giving issues: Configuration with name 'kspJvm' not found.
vi...@gmail.com <vi...@gmail.com> #28
Let me clarify something.. The room for client applications works properly when integrated with kmp library in local. i.e when using it as a whole/same project. But We would like to host library as a separate sdk.
I don't know how it is working for client applications. When we build the shared module(kmp) as standalone it shows error. But when we create new Android module within the project and access it from there it runs properly.
CASE: 1 //works fine
Project [
module1 = Android
module2 = kmp library
]
Shows compile error in module2 database file but while running the android application, all the room operations works fine.
CASE: 2 // our use case
Project [
module1 = kmp library
]
Build fails with the error saying 'The constructor is not abstract and does not implement abstract member initialize'.
We need to generate executables and host it as an sdk.
Kindly consider this use-case and provide us the solution.
Detailed error description:
e:file:///Users/..../kmp_project/zdckey_core/src/commonMain/kotlin/com/..../zdckey_core/data/database/ZDCKeyCoreDatabase.kt:21:8 Object 'ZDCKeyCoreDatabaseConstructor' is not abstract and does not implement abstract member 'initialize'.
an...@gmail.com <an...@gmail.com> #29
an...@gmail.com <an...@gmail.com> #30
Hello again
I corrected your observations and I still have the same error in iOS Xcode,these are the logs I receive when I do the clean rebuild. My error is: null cannot be cast to non-null type org.jetbrains.kotlin.load.java.structure.impl.JavaClassImpl
I attached two images for a better look. Thanks for the support.
da...@google.com <da...@google.com> #31
re ./gradlew :composeApp:kspKotlinIosX64 --stacktrace
? The error null cannot be cast to non-null type org.jetbrains.kotlin.load.java.structure.impl.JavaClassImpl
is new and might not be relevant to this specific bug.
vi...@gmail.com <vi...@gmail.com> #32
Our usecase is to generate aar and xcframework files from a standalone kmp library without any other android or ios modules.
Project [
module1 = kmp library
]
Detailed error description:
e:file:///Users/..../kmp_project/zdckey_core/src/commonMain/kotlin/com/..../zdckey_core/data/database/ZDCKeyCoreDatabase.kt:21:8 Object 'ZDCKeyCoreDatabaseConstructor' is not abstract and does not implement abstract member 'initialize'.
Is there any solutions for this usecase..! Kindly suggest any workaround. Thanks in advance..
an...@gmail.com <an...@gmail.com> #33
an...@gmail.com <an...@gmail.com> #34
re
This is the full stacktrace:
% ./gradlew :composeApp:kspKotlinIosX64 --stacktrace Type-safe project accessors is an incubating feature.
Task :composeApp:kspKotlinIosX64 FAILED e: [ksp] java.lang.NullPointerException: null cannot be cast to non-null type org.jetbrains.kotlin.load.java.structure.impl.JavaClassImpl
FAILURE: Build failed with an exception.
What went wrong: Execution failed for task ':composeApp:kspKotlinIosX64'. A failure occurred while executing com.google.devtools.ksp.gradle.KspAAWorkerAction null cannot be cast to non-null type org.jetbrains.kotlin.load.java.structure.impl.JavaClassImpl
Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights. Get more help at
Exception is: org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':composeApp:kspKotlinIosX64'. at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$1(ExecuteActionsTaskExecuter.java:130) at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:282) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeIfValid(ExecuteActionsTaskExecuter.java:128) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:116) at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:46) at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.java:51) at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:57) at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:74) at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36) at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:77) at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:55) at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52) at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:200) at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:195) at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66) at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59) at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157) at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59) at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:53) at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:73) at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:52) at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:42) at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:331) at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:318) at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.lambda$execute$0(DefaultTaskExecutionGraph.java:314) at org.gradle.internal.operations.CurrentBuildOperationRef.with(CurrentBuildOperationRef.java:80) at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:314) at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:303) at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:463) at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:380) at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64) at org.gradle.internal.concurrent.AbstractManagedExecutor$1.run(AbstractManagedExecutor.java:47) Caused by: org.gradle.workers.internal.DefaultWorkerExecutor$WorkExecutionException: A failure occurred while executing com.google.devtools.ksp.gradle.KspAAWorkerAction at org.gradle.workers.internal.DefaultWorkerExecutor$WorkItemExecution.waitForCompletion(DefaultWorkerExecutor.java:287) at org.gradle.internal.work.DefaultAsyncWorkTracker.lambda$waitForItemsAndGatherFailures$2(DefaultAsyncWorkTracker.java:130) at org.gradle.internal.Factories$1.create(Factories.java:31) at org.gradle.internal.work.DefaultWorkerLeaseService.withoutLocks(DefaultWorkerLeaseService.java:336) at org.gradle.internal.work.DefaultWorkerLeaseService.withoutLocks(DefaultWorkerLeaseService.java:319) at org.gradle.internal.work.DefaultWorkerLeaseService.withoutLock(DefaultWorkerLeaseService.java:324) at org.gradle.internal.work.DefaultAsyncWorkTracker.waitForItemsAndGatherFailures(DefaultAsyncWorkTracker.java:126) at org.gradle.internal.work.DefaultAsyncWorkTracker.waitForItemsAndGatherFailures(DefaultAsyncWorkTracker.java:92) at org.gradle.internal.work.DefaultAsyncWorkTracker.waitForAll(DefaultAsyncWorkTracker.java:78) at org.gradle.internal.work.DefaultAsyncWorkTracker.waitForCompletion(DefaultAsyncWorkTracker.java:66) at org.gradle.api.internal.tasks.execution.TaskExecution$3.run(TaskExecution.java:252) at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:29) at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:26) at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66) at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59) at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157) at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59) at org.gradle.internal.operations.DefaultBuildOperationRunner.run(DefaultBuildOperationRunner.java:47) at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:68) at org.gradle.api.internal.tasks.execution.TaskExecution.executeAction(TaskExecution.java:229) at org.gradle.api.internal.tasks.execution.TaskExecution.executeActions(TaskExecution.java:212) at org.gradle.api.internal.tasks.execution.TaskExecution.executeWithPreviousOutputFiles(TaskExecution.java:195) at org.gradle.api.internal.tasks.execution.TaskExecution.execute(TaskExecution.java:162) at org.gradle.internal.execution.steps.ExecuteStep.executeInternal(ExecuteStep.java:105) at org.gradle.internal.execution.steps.ExecuteStep.access$000(ExecuteStep.java:44) at org.gradle.internal.execution.steps.ExecuteStep$1.call(ExecuteStep.java:59) at org.gradle.internal.execution.steps.ExecuteStep$1.call(ExecuteStep.java:56) at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:200) at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:195) at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66) at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59) at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157) at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59) at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:53) at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:73) at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:56) at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:44) at org.gradle.internal.execution.steps.CancelExecutionStep.execute(CancelExecutionStep.java:41) at org.gradle.internal.execution.steps.TimeoutStep.executeWithoutTimeout(TimeoutStep.java:74) at org.gradle.internal.execution.steps.TimeoutStep.execute(TimeoutStep.java:55) at org.gradle.internal.execution.steps.PreCreateOutputParentsStep.execute(PreCreateOutputParentsStep.java:50) at org.gradle.internal.execution.steps.PreCreateOutputParentsStep.execute(PreCreateOutputParentsStep.java:28) at org.gradle.internal.execution.steps.RemovePreviousOutputsStep.execute(RemovePreviousOutputsStep.java:67) at org.gradle.internal.execution.steps.RemovePreviousOutputsStep.execute(RemovePreviousOutputsStep.java:37) at org.gradle.internal.execution.steps.BroadcastChangingOutputsStep.execute(BroadcastChangingOutputsStep.java:61) at org.gradle.internal.execution.steps.BroadcastChangingOutputsStep.execute(BroadcastChangingOutputsStep.java:26) at org.gradle.internal.execution.steps.CaptureOutputsAfterExecutionStep.execute(CaptureOutputsAfterExecutionStep.java:67) at org.gradle.internal.execution.steps.CaptureOutputsAfterExecutionStep.execute(CaptureOutputsAfterExecutionStep.java:45) at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:40) at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:29) at org.gradle.internal.execution.steps.BuildCacheStep.executeWithoutCache(BuildCacheStep.java:189) at org.gradle.internal.execution.steps.BuildCacheStep.lambda$execute$1(BuildCacheStep.java:75) at org.gradle.internal.Either$Right.fold(Either.java:175) at org.gradle.internal.execution.caching.CachingState.fold(CachingState.java:62) at org.gradle.internal.execution.steps.BuildCacheStep.execute(BuildCacheStep.java:73) at org.gradle.internal.execution.steps.BuildCacheStep.execute(BuildCacheStep.java:48) at org.gradle.internal.execution.steps.StoreExecutionStateStep.execute(StoreExecutionStateStep.java:46) at org.gradle.internal.execution.steps.StoreExecutionStateStep.execute(StoreExecutionStateStep.java:35) at org.gradle.internal.execution.steps.SkipUpToDateStep.executeBecause(SkipUpToDateStep.java:76) at org.gradle.internal.execution.steps.SkipUpToDateStep.lambda$execute$2(SkipUpToDateStep.java:54) at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:54) at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:36) at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:37) at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:27) at org.gradle.internal.execution.steps.ResolveIncrementalCachingStateStep.executeDelegate(ResolveIncrementalCachingStateStep.java:49) at org.gradle.internal.execution.steps.ResolveIncrementalCachingStateStep.executeDelegate(ResolveIncrementalCachingStateStep.java:27) at org.gradle.internal.execution.steps.AbstractResolveCachingStateStep.execute(AbstractResolveCachingStateStep.java:71) at org.gradle.internal.execution.steps.AbstractResolveCachingStateStep.execute(AbstractResolveCachingStateStep.java:39) at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:65) at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:36) at org.gradle.internal.execution.steps.ValidateStep.execute(ValidateStep.java:106) at org.gradle.internal.execution.steps.ValidateStep.execute(ValidateStep.java:55) at org.gradle.internal.execution.steps.AbstractCaptureStateBeforeExecutionStep.execute(AbstractCaptureStateBeforeExecutionStep.java:64) at org.gradle.internal.execution.steps.AbstractCaptureStateBeforeExecutionStep.execute(AbstractCaptureStateBeforeExecutionStep.java:43) at org.gradle.internal.execution.steps.AbstractSkipEmptyWorkStep.executeWithNonEmptySources(AbstractSkipEmptyWorkStep.java:125) at org.gradle.internal.execution.steps.AbstractSkipEmptyWorkStep.execute(AbstractSkipEmptyWorkStep.java:61) at org.gradle.internal.execution.steps.AbstractSkipEmptyWorkStep.execute(AbstractSkipEmptyWorkStep.java:36) at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsStartedStep.execute(MarkSnapshottingInputsStartedStep.java:38) at org.gradle.internal.execution.steps.LoadPreviousExecutionStateStep.execute(LoadPreviousExecutionStateStep.java:36) at org.gradle.internal.execution.steps.LoadPreviousExecutionStateStep.execute(LoadPreviousExecutionStateStep.java:23) at org.gradle.internal.execution.steps.HandleStaleOutputsStep.execute(HandleStaleOutputsStep.java:75) at org.gradle.internal.execution.steps.HandleStaleOutputsStep.execute(HandleStaleOutputsStep.java:41) at org.gradle.internal.execution.steps.AssignMutableWorkspaceStep.lambda$execute$0(AssignMutableWorkspaceStep.java:35) at org.gradle.api.internal.tasks.execution.TaskExecution$4.withWorkspace(TaskExecution.java:289) at org.gradle.internal.execution.steps.AssignMutableWorkspaceStep.execute(AssignMutableWorkspaceStep.java:31) at org.gradle.internal.execution.steps.AssignMutableWorkspaceStep.execute(AssignMutableWorkspaceStep.java:22) at org.gradle.internal.execution.steps.ChoosePipelineStep.execute(ChoosePipelineStep.java:40) at org.gradle.internal.execution.steps.ChoosePipelineStep.execute(ChoosePipelineStep.java:23) at org.gradle.internal.execution.steps.ExecuteWorkBuildOperationFiringStep.lambda$execute$2(ExecuteWorkBuildOperationFiringStep.java:67) at org.gradle.internal.execution.steps.ExecuteWorkBuildOperationFiringStep.execute(ExecuteWorkBuildOperationFiringStep.java:67) at org.gradle.internal.execution.steps.ExecuteWorkBuildOperationFiringStep.execute(ExecuteWorkBuildOperationFiringStep.java:39) at org.gradle.internal.execution.steps.IdentityCacheStep.execute(IdentityCacheStep.java:46) at org.gradle.internal.execution.steps.IdentityCacheStep.execute(IdentityCacheStep.java:34) at org.gradle.internal.execution.steps.IdentifyStep.execute(IdentifyStep.java:48) at org.gradle.internal.execution.steps.IdentifyStep.execute(IdentifyStep.java:35) at org.gradle.internal.execution.impl.DefaultExecutionEngine$1.execute(DefaultExecutionEngine.java:61) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeIfValid(ExecuteActionsTaskExecuter.java:127) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:116) at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:46) at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.java:51) at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:57) at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:74) at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36) at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:77) at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:55) at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52) at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:200) at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:195) at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66) at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59) at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157) at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59) at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:53) at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:73) at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:52) at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:42) at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:331) at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:318) at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.lambda$execute$0(DefaultTaskExecutionGraph.java:314) at org.gradle.internal.operations.CurrentBuildOperationRef.with(CurrentBuildOperationRef.java:80) at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:314) at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:303) at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:463) at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:380) at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64) at org.gradle.internal.concurrent.AbstractManagedExecutor$1.run(AbstractManagedExecutor.java:47) Caused by: java.lang.NullPointerException: null cannot be cast to non-null type org.jetbrains.kotlin.load.java.structure.impl.JavaClassImpl at com.google.devtools.ksp.impl.symbol.kotlin.UtilKt.getDefaultValue(util.kt:590) at com.google.devtools.ksp.impl.symbol.kotlin.resolved.KSAnnotationResolvedImpl$defaultArguments$2.invoke(KSAnnotationResolvedImpl.kt:88) at com.google.devtools.ksp.impl.symbol.kotlin.resolved.KSAnnotationResolvedImpl$defaultArguments$2.invoke(KSAnnotationResolvedImpl.kt:64) at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74) at com.google.devtools.ksp.impl.symbol.kotlin.resolved.KSAnnotationResolvedImpl.getDefaultArguments(KSAnnotationResolvedImpl.kt:64) at com.google.devtools.ksp.impl.symbol.kotlin.resolved.KSAnnotationResolvedImpl$arguments$2.invoke(KSAnnotationResolvedImpl.kt:57) at com.google.devtools.ksp.impl.symbol.kotlin.resolved.KSAnnotationResolvedImpl$arguments$2.invoke(KSAnnotationResolvedImpl.kt:54) at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74) at com.google.devtools.ksp.impl.symbol.kotlin.resolved.KSAnnotationResolvedImpl.getArguments(KSAnnotationResolvedImpl.kt:54) at com.google.devtools.ksp.impl.symbol.kotlin.KSPropertyDeclarationImpl$annotations$2$4.invoke(KSPropertyDeclarationImpl.kt:76) at com.google.devtools.ksp.impl.symbol.kotlin.KSPropertyDeclarationImpl$annotations$2$4.invoke(KSPropertyDeclarationImpl.kt:72) at kotlin.sequences.FilteringSequence$iterator$1.calcNext(Sequences.kt:171) at kotlin.sequences.FilteringSequence$iterator$1.hasNext(Sequences.kt:194) at kotlin.sequences.FlatteningSequence$iterator$1.ensureItemIterator(Sequences.kt:331) at kotlin.sequences.FlatteningSequence$iterator$1.hasNext(Sequences.kt:318) at kotlin.sequences.SequencesKt___SequencesKt.any(_Sequences.kt:1240) at ksp.com.google.devtools.ksp.common.visitor.CollectAnnotatedSymbolsVisitor.visitAnnotated(CollectAnnotatedSymbolsVisitor.kt:37) at ksp.com.google.devtools.ksp.common.visitor.CollectAnnotatedSymbolsVisitor.visitPropertyDeclaration(CollectAnnotatedSymbolsVisitor.kt:82) at ksp.com.google.devtools.ksp.common.visitor.CollectAnnotatedSymbolsVisitor.visitPropertyDeclaration(CollectAnnotatedSymbolsVisitor.kt:33) at com.google.devtools.ksp.impl.symbol.kotlin.KSPropertyDeclarationImpl.accept(KSPropertyDeclarationImpl.kt:189) at ksp.com.google.devtools.ksp.common.visitor.CollectAnnotatedSymbolsVisitor.visitClassDeclaration(CollectAnnotatedSymbolsVisitor.kt:54) at ksp.com.google.devtools.ksp.common.visitor.CollectAnnotatedSymbolsVisitor.visitClassDeclaration(CollectAnnotatedSymbolsVisitor.kt:33) at com.google.devtools.ksp.impl.symbol.kotlin.KSClassDeclarationImpl.accept(KSClassDeclarationImpl.kt:175) at ksp.com.google.devtools.ksp.common.visitor.CollectAnnotatedSymbolsVisitor.visitFile(CollectAnnotatedSymbolsVisitor.kt:43) at ksp.com.google.devtools.ksp.common.visitor.CollectAnnotatedSymbolsVisitor.visitFile(CollectAnnotatedSymbolsVisitor.kt:33) at com.google.devtools.ksp.impl.symbol.kotlin.KSFileImpl.accept(KSFileImpl.kt:84) at com.google.devtools.ksp.impl.ResolverAAImpl.collectAnnotatedSymbols(ResolverAAImpl.kt:629) at com.google.devtools.ksp.impl.ResolverAAImpl.access$collectAnnotatedSymbols(ResolverAAImpl.kt:84) at com.google.devtools.ksp.impl.ResolverAAImpl$newAnnotatedSymbols$2.invoke(ResolverAAImpl.kt:640) at com.google.devtools.ksp.impl.ResolverAAImpl$newAnnotatedSymbols$2.invoke(ResolverAAImpl.kt:639) at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74) at com.google.devtools.ksp.impl.ResolverAAImpl.getNewAnnotatedSymbols(ResolverAAImpl.kt:639) at com.google.devtools.ksp.impl.ResolverAAImpl.getSymbolsWithAnnotation(ResolverAAImpl.kt:621) at com.google.devtools.ksp.processing.Resolver.getSymbolsWithAnnotation$default(Resolver.kt:48) at androidx.room.compiler.processing.ksp.KspRoundEnv.getElementsAnnotatedWith(KspRoundEnv.kt:53) at androidx.room.compiler.processing.CommonProcessorDelegate.processRound(XBasicAnnotationProcessor.kt:95) at androidx.room.compiler.processing.ksp.KspBasicAnnotationProcessor.process(KspBasicAnnotationProcessor.kt:62) at com.google.devtools.ksp.impl.KotlinSymbolProcessing.execute(KotlinSymbolProcessing.kt:538) at com.google.devtools.ksp.impl.KSPLoader$Companion.loadAndRunKSP(KSPLoader.kt:36) at com.google.devtools.ksp.impl.KSPLoader.loadAndRunKSP(KSPLoader.kt) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at com.google.devtools.ksp.gradle.KspAAWorkerAction.execute(KspAATask.kt:510) at org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:63) at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1.create(NoIsolationWorkerFactory.java:66) at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1.create(NoIsolationWorkerFactory.java:62) at org.gradle.internal.classloader.ClassLoaderUtils.executeInClassloader(ClassLoaderUtils.java:100) at org.gradle.workers.internal.NoIsolationWorkerFactory$1.lambda$execute$0(NoIsolationWorkerFactory.java:62) at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:44) at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:41) at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:200) at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:195) at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66) at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59) at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157) at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59) at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:53) at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:73) at org.gradle.workers.internal.AbstractWorker.executeWrappedInBuildOperation(AbstractWorker.java:41) at org.gradle.workers.internal.NoIsolationWorkerFactory$1.execute(NoIsolationWorkerFactory.java:59) at org.gradle.workers.internal.DefaultWorkerExecutor.lambda$submitWork$0(DefaultWorkerExecutor.java:174) at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runExecution(DefaultConditionalExecutionQueue.java:187) at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.access$700(DefaultConditionalExecutionQueue.java:120) at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner$1.run(DefaultConditionalExecutionQueue.java:162) at org.gradle.internal.Factories$1.create(Factories.java:31) at org.gradle.internal.work.DefaultWorkerLeaseService.withLocks(DefaultWorkerLeaseService.java:264) at org.gradle.internal.work.DefaultWorkerLeaseService.runAsWorkerThread(DefaultWorkerLeaseService.java:128) at org.gradle.internal.work.DefaultWorkerLeaseService.runAsWorkerThread(DefaultWorkerLeaseService.java:133) at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runBatch(DefaultConditionalExecutionQueue.java:157) at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.run(DefaultConditionalExecutionQueue.java:126) ... 2 more Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
For more on this, please refer to
BUILD FAILED in 2s 5 actionable tasks: 1 executed, 4 up-to-date
This is my build gradle
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi import org.jetbrains.kotlin.gradle.dsl.JvmTarget
plugins { alias(libs.plugins.kotlinMultiplatform) alias(libs.plugins.androidApplication) alias(libs.plugins.jetbrainsCompose) alias(libs.plugins.compose.compiler) alias(libs.plugins.kotlin.serialization) alias(libs.plugins.ksp) alias(libs.plugins.room) }
kotlin { androidTarget { @OptIn(ExperimentalKotlinGradlePluginApi::class) compilerOptions { jvmTarget.set(JvmTarget.JVM_11) } } listOf( iosX64(), iosArm64(), iosSimulatorArm64() ).forEach { iosTarget -> iosTarget.binaries.framework { baseName = "ComposeApp" isStatic = true linkerOpts.add("-lsqlite3") } }
sourceSets {
androidMain.dependencies {
implementation(compose.preview)
implementation(libs.androidx.activity.compose)
implementation(libs.core.splashscreen)
implementation(libs.ktor.client.okhttp)
implementation(libs.koin.android)
implementation(libs.koin.androidx.compose)
implementation(libs.xml.util.core.android)
implementation(libs.room.runtime.android)
}
commonMain.dependencies {
implementation(compose.runtime)
implementation(compose.foundation)
implementation(compose.material)
implementation(compose.ui)
implementation(compose.components.resources)
implementation(compose.components.uiToolingPreview)
implementation(libs.bundles.ktor)
api(libs.datastore.preferences)
api(libs.datastore)
api(libs.koin.core)
implementation(libs.koin.compose)
implementation(libs.koin.compose.viewmodel)
implementation(libs.lifecycle.viewmodel)
implementation(libs.navigation.compose)
implementation(libs.xml.util.core)
implementation(libs.xml.util.serialization)
implementation(libs.room.runtime)
implementation(libs.sqlite.bundled)
}
iosMain {
dependencies{
implementation(libs.ktor.client.darwin)
}
}
} }
android { namespace = "com.itlab.match_academico" compileSdk = libs.versions.android.compileSdk.get().toInt()
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml") sourceSets["main"].res.srcDirs("src/androidMain/res") sourceSets["main"].resources.srcDirs("src/commonMain/resources")
defaultConfig { applicationId = "com.itlab.match_academico" minSdk = libs.versions.android.minSdk.get().toInt() targetSdk = libs.versions.android.targetSdk.get().toInt() versionCode = 1 versionName = "1.0" } packaging { resources { excludes += "/META-INF/{AL2.0,LGPL2.1}" } } buildTypes { getByName("release") { isMinifyEnabled = false } } compileOptions { sourceCompatibility = JavaVersion.VERSION_11 targetCompatibility = JavaVersion.VERSION_11 } buildFeatures { compose = true } dependencies { debugImplementation(compose.uiTooling) } }
room { schemaDirectory("$projectDir/schemas") }
dependencies { // Android add("kspAndroid", libs.room.compiler) // iOS add("kspIosSimulatorArm64", libs.room.compiler) add("kspIosX64", libs.room.compiler) add("kspIosArm64", libs.room.compiler) }
da...@google.com <da...@google.com> #35
re
re
vi...@gmail.com <vi...@gmail.com> #36
Below is the only error which we are facing.
Detailed error description:
e:file:///Users/..../kmp_project/zdckey_core/src/commonMain/kotlin/com/..../zdckey_core/data/database/ZDCKeyCoreDatabase.kt:21:8 Object 'ZDCKeyCoreDatabaseConstructor' is not abstract and does not implement abstract member 'initialize'.
The above error seems specific to the latest API change in alpha06. Actual implementations are generated by KSP in all the target sourcesets properly. But this error indicates that it expects implementation in commonmain too..
Kindly consider this error description and help us to find the root cause.. and the solution to fix it.
er...@gmail.com <er...@gmail.com> #37
e:file:///Users/..../kmp_project/zdckey_core/src/commonMain/kotlin/com/..../zdckey_core/data/database/ZDCKeyCoreDatabase.kt:21:8 Object 'ZDCKeyCoreDatabaseConstructor' is not abstract and does not implement abstract member 'initialize'.
Buddy. maybe you have some erros in ZDCKeyCoreDatabase.kt
.
You should not directly implement SDCKeyCoreDatabaseConstructor
. You let it be just expect object.
Can you upload the declaration of SDCKeyCoreDatabase
and implementation (in your case, it looks like you implement actual object) of ZDCKeyCoreDatabaseConstructor
?
vi...@gmail.com <vi...@gmail.com> #38
Nope.. brother, I didn't. I let the KSP to implement actuals in the respective target platforms and it did. i.e in androidMain and in iOSMain (in the build ->generated -> ksp folders obviously)
The problem here is as per the error description it seeks the implementation in commonMain where the expect object is defined. This is weird.
I hope the problem is clear now!
I will share the attachment for proof.
proof-1 will show the error description and the way i implemented ZDCCoreDatabase.
proof-2 will show that the actuals were generated by ksp in their respective target directories of build folder.
So please somebody look into the actual problem.. :).
er...@gmail.com <er...@gmail.com> #39
can I ask what proof_1.png
source is located in? It should be in commonMain
.
If you can find the auto-generated actual object, can you upload?
pr...@google.com <pr...@google.com> #40
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.room:room-common:2.7.0-alpha06
androidx.room:room-common-iosarm64:2.7.0-alpha06
androidx.room:room-common-iossimulatorarm64:2.7.0-alpha06
androidx.room:room-common-iosx64:2.7.0-alpha06
androidx.room:room-common-jvm:2.7.0-alpha06
androidx.room:room-common-linuxx64:2.7.0-alpha06
androidx.room:room-common-macosarm64:2.7.0-alpha06
androidx.room:room-common-macosx64:2.7.0-alpha06
androidx.room:room-compiler:2.7.0-alpha06
androidx.room:room-gradle-plugin:2.7.0-alpha06
androidx.room:room-runtime:2.7.0-alpha06
androidx.room:room-runtime-android:2.7.0-alpha06
androidx.room:room-runtime-iosarm64:2.7.0-alpha06
androidx.room:room-runtime-iossimulatorarm64:2.7.0-alpha06
androidx.room:room-runtime-iosx64:2.7.0-alpha06
androidx.room:room-runtime-jvm:2.7.0-alpha06
androidx.room:room-runtime-linuxx64:2.7.0-alpha06
androidx.room:room-runtime-macosarm64:2.7.0-alpha06
androidx.room:room-runtime-macosx64:2.7.0-alpha06
androidx.room:room-testing:2.7.0-alpha06
androidx.room:room-testing-android:2.7.0-alpha06
androidx.room:room-testing-iosarm64:2.7.0-alpha06
androidx.room:room-testing-iossimulatorarm64:2.7.0-alpha06
androidx.room:room-testing-iosx64:2.7.0-alpha06
androidx.room:room-testing-jvm:2.7.0-alpha06
androidx.room:room-testing-linuxx64:2.7.0-alpha06
androidx.room:room-testing-macosarm64:2.7.0-alpha06
androidx.room:room-testing-macosx64:2.7.0-alpha06
vi...@gmail.com <vi...@gmail.com> #41
Yes, of course it is located in commonMain.I haven't shared the package structure because it violates our org policy.
I will share the requested screenshots with blurred package names. Please check and let me know your thoughts..
vi...@gmail.com <vi...@gmail.com> #42
Hii pr...@google.com
I am not getting it.. We are already using 2.7.0-alpha06 only! which is where RoomDatabaseConstructor & @ConstructedBy annotation api's are introduced.
"It is possible this bug has only been partially addressed:"
Here you mean this usecase is missed in this version of release?. Kindly clarify us..
Is there any workaround?
da...@google.com <da...@google.com> #43
Here is a sample project using Kotlin 2.0, Compose KMP and Room KMP 2.7.0-alpha06 in a library module:
I hope it serves as guidance, otherwise without a small repro project it is hard for us to point you in the right direction to fix your issue. Let me know if it is helpful.
er...@gmail.com <er...@gmail.com> #44
In my opinion.. your compiler version doesn't support actual
/ expect
. Can you check your Kotlin, KSP, Compose Version and talk to me?
vi...@gmail.com <vi...@gmail.com> #45
Buddy, our compiler version does support expect & actual. We have expect actual implementations for network, datastore related apis in our project. The room constructedby API is the only problem we are facing.
If you ask for versions, we are using kotlin 2.0 and its compatible ksp version.
ha...@gmail.com <ha...@gmail.com> #46
Am facing the same error. Please took this as a priority. We are halfway into the release.
If it is an issue in this please let us know, we will look for alternatives for the time being. Kindly clarify us.
vi...@gmail.com <vi...@gmail.com> #47
Dear da...@google.com
Thanks a lot for taking time and build this sample project for us.
The mentioned issue reproduced in your project too. If we run the android application, it will run. But when we rebuild the project it will get failed throwing an error in the shared/library module.
e: file:///Users/.../Documents/RoomKmpLibraryExample/data/src/commonMain/kotlin/com/example/data/MyDatabase.kt:19:8 Object 'MyDatabaseCtor' is not abstract and does not implement abstract member 'initialize'.
In our use case we will not bind app and library modules in a same project. We will generate aar, xcframework files and host it in our org repository.
Attaching the screenshot for your reference.
Again, thanks for making the efforts. We sincerely appreciate it.
ph...@bayf.net <ph...@bayf.net> #48
After following all the guidance and checking the sample project I'm still getting: Object 'MyDatabaseCtor' is not abstract and does not implement abstract member 'initialize'
ma...@gmail.com <ma...@gmail.com> #49
er...@gmail.com <er...@gmail.com> #50
I have a similar error like yours when rebuild gradle.
'actual object AlarmDatabaseCtor : RoomDatabaseConstructor<AlarmDatabase>' has no corresponding expected declaration
However it works without error at my database.
da...@google.com <da...@google.com> #51
So it seems the issue is when either running ./gradlew build
or via Build -> Rebuild Project
in the IDE. This is important information since those actions tend to build 'too many things'. Specially it tries to build common source set in isolation (compileCommonMainKotlinMetadata
) which is a grey area in Kotlin right now, due to the expect / actual compilation model it is not possible to publish a 'common-only' library that has expect / actual as consumers can't contribute to those, i.e. you always publish -common
along side a platform.
I agree building via those two actions is broken. But are they hindering the rest of your project if iOS (via XCode), JVM Desktop (via ./gradlew composeApp:run
) and Android (via Android Studio) launch and work as expected? Or are they preventing you from publishing a library?
If it is still valuable to you to have a successful build via ./gradlew build
then we actually just made a fix for this (see initialize
override function in the expect object
and then the generated code will also include the actual
modifier. You can try this right now with a snapshot version of Room (see ./gradlew build
containing the fix in
ph...@bayf.net <ph...@bayf.net> #52
In my case, run via Android Studio, run via Xcode, Android CI (./gradlew build
) and iOS CI (xcodebuild archive
) are all broken with the same error. I've not managed to get a successful build to run with the latest alpha. It's a multi-module CMP project, it's virtually identical to your example project, in terms of Gradle and database initialisation, but with several entity types and DAOs added.
Edit: With snapshot, everything is working 👌🏻
vi...@gmail.com <vi...@gmail.com> #53
Thanks for the update da..@google.com. This is the clarity we want.. Some issue is found and it will be resolved in the next alpha release. This is the exact issue am trying to point out from beginning. As you mentioned this issue preventing us from publishing a library. I am glad this conversation has come to a conclusion. I sincerely appreciate your relentless response.
av...@gmail.com <av...@gmail.com> #54
From
on 8/15/2024: issue 358393367
re
Just one question, it seems to me that we can get XXDatabase info through the @Database annotation. I haven't seen the specific code, but I guess XXDatabase_Impl is also generated in this way? Is it possible generate expect object XXDatabaseConstructor : RoomDatabaseConstructor<XXDatabase>
automatally without any intervention?
av...@gmail.com <av...@gmail.com> #55
From
on 8/11/2024: issue 358913889
Update! Problems solved by doing things
- disable room gradle plugin and rewrite
ksp { .... }
as you mentioned. - update kotlin and ksp version to 2.0.10
I think this is just temporary solution, however anyway it works now. I hope next version of room should be fixed ... :) thanks for your help!
st...@gmail.com <st...@gmail.com> #56
an...@gmail.com <an...@gmail.com> #57
Hi, I encountered a similar problem running KMM iOS build (room+ksp) 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"
Description
Version used:
androidxRoom = "2.7.0-alpha02"
sqlite = "2.5.0-alpha02"
ksp = "1.9.23-1.0.19"
kotlin = "1.9.23"
and 1 try
kotlin = "2.0.0"
ksp = "2.0.0-1.0.21"
Devices/Android versions reproduced on:
iOS
fun getDatabaseBuilder(): RoomDatabase.Builder<AppDatabase> {
val dbFilePath = NSHomeDirectory() + "/location-database.db"
return Room.databaseBuilder<AppDatabase>(
name = dbFilePath,
factory = { AppDatabase::class.instantiateImpl() }
).setDriver(BundledSQLiteDriver())
.setQueryCoroutineContext(Dispatchers.IO)
}
Unresolved reference: instantiateImpl
ksp has generated an extension function whose name is instantiateImpl, but the project is not going to be built.
Unresolved reference: instantiateImpl
suggests adding a dependency - Add dependency on module 'project.module.core.iosX64Main'