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

Unresolved reference: string in the generated MR.kt #403

Closed
saravr opened this issue Dec 29, 2022 · 7 comments · Fixed by #439
Closed

Unresolved reference: string in the generated MR.kt #403

saravr opened this issue Dec 29, 2022 · 7 comments · Fixed by #439
Assignees
Labels
bug Something isn't working
Milestone

Comments

@saravr
Copy link

saravr commented Dec 29, 2022

I created a minimal multiplatform library (for Android and iOS) but ran into the error ...shared/build/generated/moko/androidMain/src/com/example/mokotest/MR.kt: (16, 68): Unresolved reference: string for the command ./gradlew assemble.

I followed the README up until executing ./gradlew generateMRcommonMain.

My sample repo is at https://github.com/saravr/MokoTest.

All I need is to define string resources that are defined in commonMain and used in Android and iOS code in the shared module. Android Gradle Plugin version is 7.3.1 and Kotlin version is 1.7.20. What am I missing? Any help is appreciated.

Including shared gradle file:

import org.jetbrains.kotlin.gradle.plugin.mpp.apple.XCFramework

plugins {
    kotlin("multiplatform")
    kotlin("native.cocoapods")
    id("com.android.library")
    id("dev.icerock.mobile.multiplatform-resources")
}

group = "com.example"
version = "1.0.0"

kotlin {
    val xcf = XCFramework()

    android()
    iosX64()
    iosArm64()
    iosSimulatorArm64 {
        binaries.framework {
            baseName = "shared"
            xcf.add(this)
        }
    }

    cocoapods {
        summary = "Some description for the Shared Module"
        homepage = "Link to the Shared Module homepage"
        version = "1.0"
        ios.deploymentTarget = "14.1"
        framework {
            baseName = "shared"
        }
    }
    
    sourceSets {
        val commonMain by getting
        val commonTest by getting {
            dependencies {
                implementation(kotlin("test"))
            }
        }
        val androidMain by getting {
            dependencies {
                api("dev.icerock.moko:resources-compose:0.20.1")
            }
        }
        val androidTest by getting
        val iosX64Main by getting
        val iosArm64Main by getting
        val iosSimulatorArm64Main by getting
        val iosMain by creating {
            dependsOn(commonMain)
            iosX64Main.dependsOn(this)
            iosArm64Main.dependsOn(this)
            iosSimulatorArm64Main.dependsOn(this)
        }
        val iosX64Test by getting
        val iosArm64Test by getting
        val iosSimulatorArm64Test by getting
        val iosTest by creating {
            dependsOn(commonTest)
            iosX64Test.dependsOn(this)
            iosArm64Test.dependsOn(this)
            iosSimulatorArm64Test.dependsOn(this)
        }
    }
}

dependencies {
    commonMainApi("dev.icerock.moko:resources:0.20.1")
}

multiplatformResources {
    multiplatformResourcesPackage = "com.example.mokotest" // required
}

android {
    namespace = "com.example.mokotest"
    compileSdk = 32
    defaultConfig {
        minSdk = 23
        targetSdk = 32
    }
}
@Alex009
Copy link
Member

Alex009 commented Dec 30, 2022

hi!
Android Gradle Plugin 7.3.0 have issue with resources dir that we use.
as workaround you can use android 7.2.2 or #353 (comment)
in AGP 7.4.0 issue should be fixed https://issuetracker.google.com/issues/255784699

@Alex009
Copy link
Member

Alex009 commented Dec 30, 2022

we try to fix issue inside our plugin, but at now we not resolve this yet

@Alex009 Alex009 added this to the 0.20.2 milestone Dec 30, 2022
@Alex009 Alex009 added the bug Something isn't working label Dec 30, 2022
@saravr
Copy link
Author

saravr commented Dec 31, 2022

Thanks. Actually all I needed was the addition mentioned in the comment. It worked even with existing AGP 7.3.1. Thanks for the pointer!

@Burtan
Copy link
Contributor

Burtan commented Jan 20, 2023

I think this problem still exists in the final agp 7.4.0

@hulkdx
Copy link

hulkdx commented Feb 6, 2023

Thanks. Actually all I needed was the addition mentioned in the comment. It worked even with existing AGP 7.3.1. Thanks for the pointer!

android {
    sourceSets["main"].res.srcDir(File(buildDir, "generated/moko/androidMain/res"))
}

@kaszabimre
Copy link

The problem is still exist with 7.4.1 :(

@Alex009 Alex009 modified the milestones: 0.21.0, 0.21.1 Mar 3, 2023
@Alex009 Alex009 modified the milestones: 0.21.1, 0.21.0 Mar 12, 2023
@Alex009 Alex009 self-assigned this Mar 12, 2023
@Alex009
Copy link
Member

Alex009 commented Mar 24, 2023

will be released in 0.21.0

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
Status: No status
5 participants