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

Unable to compile after trying to update to 0.24.0: Unable to find method GenerateMultiplatformResourcesTask.onlyIf #732

Closed
bravo-delta opened this issue Jun 10, 2024 · 5 comments · Fixed by #735 or #736
Labels
bug Something isn't working
Milestone

Comments

@bravo-delta
Copy link

First of all: Thanks for all the efforts that went into the 0.24.0 Update

I tried to update my project to 0.24.0 but during compilation the following error is thrown:
java.lang.NoSuchMethodError: 'void dev.icerock.gradle.tasks.GenerateMultiplatformResourcesTask.onlyIf(java.lang.String, org.gradle.api.specs.Spec)' at dev.icerock.gradle.extra.MokoResourcesGenTaskKt$registerGenerateTask$taskProvider$1.invoke(mokoResourcesGenTask.kt:110) at dev.icerock.gradle.extra.MokoResourcesGenTaskKt$registerGenerateTask$taskProvider$1.invoke(mokoResourcesGenTask.kt:78) at dev.icerock.gradle.extra.MokoResourcesGenTaskKt.registerGenerateTask$lambda$0(mokoResourcesGenTask.kt:81) at org.gradle.api.internal.DefaultMutationGuard$2.execute(DefaultMutationGuard.java:44) at org.gradle.api.internal.DefaultMutationGuard$2.execute(DefaultMutationGuard.java:44)

What I did:

  • moved resources from src\commonMain\resources\MR to src\commonMain\moko-resources
  • changed dependency in build.gradle:
    buildscript { dependencies { [...] classpath: "dev.icerock.moko:resources-generator:0.24.0" } }
  • Changed multiplatformResources in build.gradle.kts:
    multiplatformResources { resourcesPackage.set("com.example.projectname") iosBaseLocalizationRegion.set("en") }
  • Updated the dependency version in build.gradle.kts to 0.24.0
  • Kotlin 1.9.20
  • Android Studio Iguana | 2023.2.1 Patch 1

Somehow there seems to be an issue with caching, because the IDE says that the resourcesPackage property of multiplatformResources in the build.gradle.kts file is an unresolved reference. If I go to the declaration of the multiplatformResources it opens the old 0.23.0.jar
I cleared various cache folders, including the ~/.gradle/ folder, which contains the ~/.gradle/caches/jars-9/..../resources-generator-0.24.0.jar and 0.23.0.jar, but to no avail.

Any ideas, what might be wrong?

If I change back the resources-generator class path dependency to 0.23.0 it compiles, but of course all resources are empty, because they are located in the new directory moko-resources, where the old generator does not search for them.

@Alex009
Copy link
Member

Alex009 commented Jun 10, 2024

Hi. What gradle version used?

@bravo-delta
Copy link
Author

bravo-delta commented Jun 10, 2024

Hello, I'm running gradle 7.5.

Thanks for the pointer, that seems to be the issue.
It looks like the update to Kotlin 1.9.20 requires gradle 8.5

The error went away.
I was only looking at the minimum requirement of Gradle 7.5 that is mentioned in the moko-resources description and did not look at the one that Kotlin requires.

There is a new error now, but that seems to be related to a resource, where the previous moko version was less restrictive maybe.

java.lang.StringIndexOutOfBoundsException: String index out of range: 0 at dev.icerock.gradle.utils.StringExtKt.convertXmlStringToAndroidLocalization(StringExt.kt:66) at dev.icerock.gradle.generator.resources.string.AndroidStringResourceGenerator.generateLanguageFile(AndroidStringResourceGenerator.kt:73) at dev.icerock.gradle.generator.resources.string.AndroidStringResourceGenerator.generateResourceFiles(AndroidStringResourceGenerator.kt:54) at dev.icerock.gradle.generator.ResourceTypeGenerator.generateFiles(ResourceTypeGenerator.kt:179) at dev.icerock.gradle.generator.ResourcesGenerator.generateResources(ResourcesGenerator.kt:197) at dev.icerock.gradle.tasks.GenerateMultiplatformResourcesTask.generate(GenerateMultiplatformResourcesTask.kt:166)

I'll see if I can figure that out.

@bravo-delta
Copy link
Author

bravo-delta commented Jun 10, 2024

Most likely it has to do with this change: StringExt.kt String.convertXmlStringToAndroidLocalization

I have various strings that are empty, e.g. like:
<string name="empty_string"></string>

If these are getting into that method, the call to this[0] fails.

@AntsyLich
Copy link

Another example with plurals

<plurals name="missing_chapters">
    <item quantity="one"/>
    <item quantity="other">Жоқ %1$s тараулары</item>
</plurals>

@Alex009 Alex009 linked a pull request Jun 20, 2024 that will close this issue
@Alex009 Alex009 added this to the 0.24.1 milestone Jun 20, 2024
@Alex009 Alex009 added the bug Something isn't working label Jun 20, 2024
@Alex009 Alex009 mentioned this issue Jun 20, 2024
@Alex009
Copy link
Member

Alex009 commented Jun 20, 2024

will be released in 0.24.1

@Alex009 Alex009 closed this as completed Jun 20, 2024
null2264 added a commit to null2264/yokai that referenced this issue Jun 24, 2024
* fix(deps): "String index out of range" compile error

REF: icerockdev/moko-resources#732

* refactor(i18n): Simplify gradle

* refactor: Migrate i18n files to moko-resources

Also split plurals to their own files

* fix: Only use firebase on releases

* revert: Revert "fix: Only use firebase on releases"

This reverts commit e4f40b4.

* ci: Just build standard release

* refactor: Fully migrate to Moko Resources for i18n
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants