icerockdev / moko-resources

Resources access for mobile (android & ios) Kotlin Multiplatform development
https://moko.icerock.dev/
Apache License 2.0
1.07k stars 120 forks source link

Not being generated Resources String Kotlin 2.0 #741

Closed And-DS closed 2 months ago

And-DS commented 2 months ago

I am generating String resources with Kotlin 2.0 for an app using KMM, but the SharedRes files are not being generated. Looking into the folders, they are empty. I don't know what I'm doing wrong, attaching screenshots. I am using a Mac M1 with Android Studio Koala | 2024.1.1 build.gradle project

plugins {
    //trick: for the same plugin versions in all sub-modules
    alias(libs.plugins.androidApplication).apply(false)
    alias(libs.plugins.androidLibrary).apply(false)
    alias(libs.plugins.kotlinAndroid).apply(false)
    alias(libs.plugins.kotlinMultiplatform).apply(false)
    alias(libs.plugins.compose.compiler).apply(false)

}
buildscript {
    dependencies {
        classpath("dev.icerock.moko:resources-generator:0.24.1")
    }
}

build.gradle shared module

plugins {
    alias(libs.plugins.kotlinMultiplatform)
    alias(libs.plugins.androidLibrary)
    id("dev.icerock.mobile.multiplatform-resources")

}

kotlin {
    androidTarget {
        compilations.all {
            kotlinOptions {
                jvmTarget = "1.8"
            }
        }
    }

    listOf(
        iosX64(),
        iosArm64(),
        iosSimulatorArm64()
    ).forEach {
        it.binaries.framework {
            baseName = "shared"
            isStatic = true
            export("dev.icerock.moko:resources:0.24.1")
            export("dev.icerock.moko:graphics:0.9.0") // toUIColor here
        }
    }

    sourceSets {

        commonMain.dependencies {
            api(libs.resource.moko)
        }
        commonTest.dependencies {
            implementation(libs.kotlin.test)
        }
    }

}

android {
    namespace = "com.alfran"
    compileSdk = 34
    defaultConfig {
        minSdk = 26
    }
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }
}

multiplatformResources {
    resourcesPackage.set("com.alfran")
    resourcesClassName.set("SharedRes")
}

Strings resources folder image

build generated image image

I need your help... I dont know what I doing wrong

ExNDY commented 2 months ago

Hi, please read readme and check samples. I don't know why u place moko-resources like on screens. should be: Module/src/sourceSet/moko-resources For example: shared/src/commonMain/moko-resources

And-DS commented 2 months ago

Hi, big mistake.... thanks! close issue

amijsul commented 2 days ago

You guys should've written a migration guide for 0.23.0 to 0.24.0. (the old req was to put commonMain/resources/MR) I was stuck trying to figure out why the resources were not generating when I finally stumbled upon this issue. This fixed it.

ExNDY commented 2 days ago

@amijsul Hm...We write guide in release: https://github.com/icerockdev/moko-resources/releases/tag/release%2F0.24.0 also have been updated all samples and readme.

amijsul commented 2 days ago

I did not see that, thank you for pointing it out! that guide is very helpful.