Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Mugurell opened this issue Jul 19, 2023 · 19 comments · Fixed by #575
Assignees
Labels
bug Something isn't working kotlin-update
Milestone

Comments

@Mugurell
Copy link

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 - Mugurell/KaMPKit@e628563

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 Mugurell changed the title Expected object 'MR' has no actual declaration in module <shared_debug> for JVM (sample project included) "Expected object 'MR' has no actual declaration in module <shared_debug> for JVM" (sample project included) Jul 19, 2023
@izadiegizabal
Copy link

izadiegizabal commented Jul 20, 2023

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 🤔

@alexzhirkevich
Copy link

alexzhirkevich commented Jul 20, 2023

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.

@izadiegizabal
Copy link

izadiegizabal commented Jul 21, 2023

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 #510

@ExNDY
Copy link
Contributor

ExNDY commented Jul 21, 2023

I think this's continuation of problem (or its variant): #353 (comment)
Worked solution: #510 (comment)
Tested on AGP: 8.0.1, Gradle: 8.2.1, Kotlin 1.9.0

@Mugurell
Copy link
Author

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

@Alex009
Copy link
Member

Alex009 commented Jul 21, 2023

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

@Alex009 Alex009 reopened this Jul 21, 2023
@Alex009 Alex009 added this to the 0.23.1 milestone Jul 24, 2023
@Alex009 Alex009 added bug Something isn't working kotlin-update labels Jul 24, 2023
@tanizaki-mp
Copy link

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

@mikolajefento
Copy link

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

@SongOnWater
Copy link

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

@m-sasha
Copy link

m-sasha commented Sep 3, 2023

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.

igorescodro added a commit to igorescodro/alkaa that referenced this issue Sep 5, 2023
In Kotlin 1.9.0, the following error occurs when trying to build the
project:

> Expected object 'MR' has no actual declaration in module
> <shared_debug> for JVM

Adding a explicit dependency fix the issue for now:
icerockdev/moko-resources#531
igorescodro added a commit to igorescodro/alkaa that referenced this issue Sep 5, 2023
In Kotlin 1.9.0, the following error occurs when trying to build the
project:

> Expected object 'MR' has no actual declaration in module
> <shared_debug> for JVM

Adding a explicit dependency fix the issue for now:
icerockdev/moko-resources#531
igorescodro added a commit to igorescodro/alkaa that referenced this issue Sep 6, 2023
The app is working fine on both iOS and Android, but it fails for
implicit Gradle dependencies when building it. Adding even more explicit
setup then.

icerockdev/moko-resources#531
icerockdev/moko-resources#535
igorescodro added a commit to igorescodro/alkaa that referenced this issue Sep 6, 2023
In Kotlin 1.9.0, the following error occurs when trying to build the
project:

> Expected object 'MR' has no actual declaration in module
> <shared_debug> for JVM

Adding a explicit dependency fix the issue for now:
icerockdev/moko-resources#531
igorescodro added a commit to igorescodro/alkaa that referenced this issue Sep 6, 2023
The app is working fine on both iOS and Android, but it fails for
implicit Gradle dependencies when building it. Adding even more explicit
setup then.

icerockdev/moko-resources#531
icerockdev/moko-resources#535
@bcmedeiros
Copy link

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

@Alex009 Alex009 linked a pull request Sep 11, 2023 that will close this issue
71 tasks
igorescodro added a commit to igorescodro/alkaa that referenced this issue Oct 3, 2023
In Kotlin 1.9.0, the following error occurs when trying to build the
project:

> Expected object 'MR' has no actual declaration in module
> <shared_debug> for JVM

Adding a explicit dependency fix the issue for now:
icerockdev/moko-resources#531
igorescodro added a commit to igorescodro/alkaa that referenced this issue Oct 12, 2023
In Kotlin 1.9.0, the following error occurs when trying to build the
project:

> Expected object 'MR' has no actual declaration in module
> <shared_debug> for JVM

Adding a explicit dependency fix the issue for now:
icerockdev/moko-resources#531
@maitriyogin
Copy link

maitriyogin commented Dec 10, 2023

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?

@lindsey-hughes
Copy link

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())
}

@tahaak67
Copy link

tahaak67 commented Dec 24, 2023

@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.

@titanseason
Copy link

@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

@3llomi
Copy link

3llomi commented Jan 20, 2024

@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 :(

@magdalenatsolaki
Copy link

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

worked for me:

androidMain {
    dependsOn(commonMain)
}

@ExNDY
Copy link
Contributor

ExNDY commented Apr 17, 2024

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

@Alex009
Copy link
Member

Alex009 commented Apr 19, 2024

should be fixed in 0.24.0-beta-1

@Alex009 Alex009 closed this as completed Apr 19, 2024
@Alex009 Alex009 mentioned this issue Jun 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working kotlin-update
Projects
None yet
Development

Successfully merging a pull request may close this issue.