moko-resources icon indicating copy to clipboard operation
moko-resources copied to clipboard

Expected object 'MR' has no actual declaration in module <kamel-samples_debug> for JVM

Open luca992 opened this issue 1 year ago • 7 comments

I tried updating moko-rosources from 20.1 to 22.0 in my fork of kamel, and I can't get android to build with the 22.0 moko-resources, all other targets are building fine.

The error I'm getting is Expected object 'MR' has no actual declaration in module <kamel-samples_debug> for JVM

https://github.com/luca992/Kamel/tree/moko22

I am using kotlin.mpp.androidSourceSetLayoutVersion=2 if that matters

luca992 avatar May 07 '23 21:05 luca992

as i see we should enable moko-resources gradle plugin after AGP plugin to AGP correctly read generated source set https://github.com/luca992/Kamel/pull/1

Alex009 avatar May 08 '23 14:05 Alex009

I'm experiencing the same issue. And I have no JVM target either.

Moving plugin declarations around as suggested makes no difference.

Task :frontend:modules:common:compileDebugKotlinAndroid fails with the following error:

Expected object 'commonR' has no actual declaration in module <common_debug> for JVM

But androidMain/*/commonR.kt, androidMain/*/res/*.xml and commonMain/*/commonR.kt are generated correctly.

Here are some examples of my configuration

:frontend:modules:common:build.gradle.kts

plugins {
    alias(libs.plugins.android.library)
    alias(libs.plugins.kotlin.multiplatform)
    alias(libs.plugins.moko.resources)
}

multiplatformResources {
    multiplatformResourcesPackage = "some.package.name.common"
    multiplatformResourcesClassName = "commonR"
}

kotlin {
    android { compilations.all { kotlinOptions { jvmTarget = "1.8" } } }
    iosX64()
    iosArm64()
    iosSimulatorArm64()
    js(IR) { browser() }

    sourceSets {
        val commonMain by getting {
            dependencies {
                api(libs.moko.resources)
                // ...
            }
        }
    }
    // ...
}

:build.gradle.kts

plugins {
    alias(libs.plugins.android.application) apply false
    alias(libs.plugins.android.library) apply false
    alias(libs.plugins.kotlin.android) apply false
    alias(libs.plugins.kotlin.cocoapods) apply false
    alias(libs.plugins.kotlin.multiplatform) apply false
    alias(libs.plugins.moko.resources) apply false
}

versions.toml

kotlin = "1.9.0-Beta" # 1.8.21 makes no difference
android-application = "com.android.application:7.4.0"
android-library = "com.android.library:7.4.0"
moko-resources = "dev.icerock.moko:resources:0.22.3"

xpathexception avatar May 25 '23 10:05 xpathexception

Task :frontend:modules:common:compileKotlinJs also fails with the same error:

Expected object 'commonR' has no actual declaration in module <Project.frontend.modules:common> for JS

xpathexception avatar May 25 '23 11:05 xpathexception

@xpathexception you should use AGP 7.4.2 or later

Alex009 avatar Jun 04 '23 10:06 Alex009

I'm facing the issue, moving moko-resources plugin around does not work. I've upgraded to kotlin 1.9 recently. There is no problem with kotlin 1.8.21.

KentVu avatar Aug 18 '23 10:08 KentVu

Same, with kotlin 1.9 MR try to found actual declaration, but with kotlin 1.8.21 project builds successfully

VixonneN avatar Aug 21 '23 16:08 VixonneN

I think I'm facing the same issue. A work-around was to add a dependency to commonMain to jvmMain like:

val jvmMain by getting {
    dependsOn(commonMain)
}

The works for Kotlin 1.9.10 and Compose 1.5.1.

sproctor avatar Sep 20 '23 18:09 sproctor

will be fixed in 0.24.0, please check in 0.24.0-alpha-6

ExNDY avatar Apr 17 '24 04:04 ExNDY

should be fixed in 0.24.0-beta-1

Alex009 avatar Apr 19 '24 15:04 Alex009