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

"Expected object 'MR' has no actual declaration in module <shared_debug> for JVM" (sample project included)

Open Mugurell opened this issue 2 years ago • 16 comments

Hello,

I am trying to use moko-resources v0.23.0 to be able to use "shared" strings in a compose multiplatform project but I encounter the error in the title of this issue when trying to build the application. The project and moko setup I am using can be seen here - https://github.com/Mugurell/KaMPKit/commit/e628563a547bb47635595939429093adb1dcab43

Additionally if I ask moko to build resources I get:

> ./gradlew clean
> ./gradlew generateMRcommonMain --info
Task ':shared:generateMRcommonMain' is not up-to-date because:
  Output property 'outputDirectory' file /Users/petru/Projects/Tests/KaMPKit/shared/build/generated/moko/commonMain/src/co has been removed.
  Output property 'outputDirectory' file /Users/petru/Projects/Tests/KaMPKit/shared/build/generated/moko/commonMain/src/co/touchlab has been removed.
  Output property 'outputDirectory' file /Users/petru/Projects/Tests/KaMPKit/shared/build/generated/moko/commonMain/src/co/touchlab/kampkit has been removed.
file or directory '/Users/petru/Projects/Tests/KaMPKit/shared/build/generated/moko/commonMain/res', not found
file or directory '/Users/petru/Projects/Tests/KaMPKit/shared/build/generated/moko/commonMain/res', not found
file or directory '/Users/petru/Projects/Tests/KaMPKit/shared/build/generated/moko/commonMain/res', not found
file or directory '/Users/petru/Projects/Tests/KaMPKit/shared/build/generated/moko/commonMain/res', not found
file or directory '/Users/petru/Projects/Tests/KaMPKit/shared/build/generated/moko/commonMain/res', not found
file or directory '/Users/petru/Projects/Tests/KaMPKit/shared/build/generated/moko/commonMain/res', not found
file or directory '/Users/petru/Projects/Tests/KaMPKit/shared/build/generated/moko/commonMain/res', not found

with the expect class constructed but not also with the actual ones image

Mugurell avatar Jul 19 '23 19:07 Mugurell

i just encountered this issue when upgrading my project's AGP to 8.2.0-alpha13 and kotlin to 1.9.0, it was working before. i was wondering if the kotlin update broke it but i see that you are using 1.8.22 🤔

izadiegizabal avatar Jul 20 '23 02:07 izadiegizabal

Had the same issue recently after i added string resources to the 3rd module in project. Even git rollback to the point where everything was ok didn't help =))

The only solution i found is ./gradlew clean and completely delete $USER_HOME/.gradle folder.

alexzhirkevich avatar Jul 20 '23 19:07 alexzhirkevich

i just tried cleaning the project, invalidating caches and purging $USER_HOME/.gradle but that didn't work, unfortunately. in my case rolling kotlin back to 1.8.22 seems to prevent the error though 🤔

edit: it looks like it's a known issue https://github.com/icerockdev/moko-resources/issues/510

izadiegizabal avatar Jul 21 '23 00:07 izadiegizabal

I think this's continuation of problem (or its variant): https://github.com/icerockdev/moko-resources/issues/353#issuecomment-1179713713 Worked solution: https://github.com/icerockdev/moko-resources/issues/510#issuecomment-1619141070 Tested on AGP: 8.0.1, Gradle: 8.2.1, Kotlin 1.9.0

ExNDY avatar Jul 21 '23 06:07 ExNDY

Thank you! Was trying various mix and matches of kotlin, agp and gradle but seems to indeed be just a linking issue that hopefully will get fixed in the next versions.

image

Mugurell avatar Jul 21 '23 08:07 Mugurell

issue will be fixed so we should not close this issue now :)

Alex009 avatar Jul 21 '23 11:07 Alex009

I just struggled this problem, and resolved by cleaning .gradle and using kotlin 1.8.22. thanks!!!!!

tanizaki-mp avatar Jul 24 '23 11:07 tanizaki-mp

For me the fix was to add dependsOn(commonMain) in androidMain source set

mikolajefento avatar Aug 10 '23 08:08 mikolajefento

i just encountered this issue when upgrading my project's AGP to 8.2.0-alpha13 and kotlin to 1.9.0, it was working before. i was wondering if the kotlin update broke it but i see that you are using 1.8.22 🤔

This issue is due to kotlin plugin 1.9.0. But maybe another plugin(such as com.arkivanov.parcelize.darwin 0.2.0) has used the 1.9.0 version, the higher version has the priority. Y

SongOnWater avatar Aug 23 '23 01:08 SongOnWater

Is this fixed on the moko-resources side?

I'm with the Compose-Multiplatform team, trying to understand whether this is the same issue reported here and whether any action on our part is required.

m-sasha avatar Sep 03 '23 11:09 m-sasha

In here, after adding a dependsOn(commonMain) to androidMain source set, my errors disappeared.

bcmedeiros avatar Sep 07 '23 17:09 bcmedeiros

I'm getting this issue with a fresh CMP template with kotlin 1.9.21. dependsOn is no longer with the new Gradle setup so instead I've tried

 androidMain.dependencies {
            implementation(project(":shared"))

Although this doesn't seem to work ... Any ideas?

maitriyogin avatar Dec 10 '23 09:12 maitriyogin

I'm getting this issue with a fresh CMP template with kotlin 1.9.21. dependsOn is no longer with the new Gradle setup so instead I've tried

 androidMain.dependencies {
            implementation(project(":shared"))

Although this doesn't seem to work ... Any ideas?

@maitriyogin adding this line worked for me

androidMain {
    dependsOn(commonMain.get())
}

lindsey-hughes avatar Dec 20 '23 18:12 lindsey-hughes

@maitriyogin adding this line worked for me

androidMain {
    dependsOn(commonMain.get())
}

Thanks after adding dependsOn(commonMain.get()) android build is running fine but it introduces errors with ios. if i comment the 'dependsOn' line and sync ios build works fine but the issue in op comes back on android.

tahaak67 avatar Dec 24 '23 12:12 tahaak67

@maitriyogin adding this line worked for me

androidMain {
    dependsOn(commonMain.get())
}

Thanks after adding dependsOn(commonMain.get()) android build is running fine but it introduces errors with ios. if i comment the 'dependsOn' line and sync ios build works fine but the issue in op comes back on android.

I got the same issue after adding dependsOn(commonMain.get()), iosMain not working

titanseason avatar Dec 28 '23 11:12 titanseason

@maitriyogin adding this line worked for me

androidMain {
    dependsOn(commonMain.get())
}

Thanks after adding dependsOn(commonMain.get()) android build is running fine but it introduces errors with ios. if i comment the 'dependsOn' line and sync ios build works fine but the issue in op comes back on android.

I got the same issue after adding dependsOn(commonMain.get()), iosMain not working

Same here :(

3llomi avatar Jan 20 '24 16:01 3llomi

kotlin = "1.9.23" moko = "0.23.0" compose = "1.6.1" ....

worked for me:

androidMain {
    dependsOn(commonMain)
}

magdalenatsolaki avatar Mar 26 '24 12:03 magdalenatsolaki

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

ExNDY avatar Apr 17 '24 05:04 ExNDY

should be fixed in 0.24.0-beta-1

Alex009 avatar Apr 19 '24 15:04 Alex009