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

Moko-Resource is not getting resource in Android if dependency isn't defining in consumer project #773

Open
AliAzaz opened this issue Sep 11, 2024 · 2 comments

Comments

@AliAzaz
Copy link

AliAzaz commented Sep 11, 2024

I am working on the KMP library in which I want to share the .js file between platforms and generate ".aar" to distribute with other consumers, but it is not fetching resources and giving an error:

Process: com.aliazaz.sampleappimportedkmplibrary, PID: 11096 java.lang.NoClassDefFoundError: Failed resolution of: Ldev/icerock/moko/resources/ResourceContainer;

This is my gradle:

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

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

kotlin {
    //android
    androidTarget {
        compilations.all {
            kotlinOptions {
                jvmTarget = "1.8"
            }
        }
        //publishLibraryVariants("release")
    }

    //iOS
    val iosArm64 = iosArm64()
    val iosX64 = iosX64()
    val iosSimulatorArm64 = iosSimulatorArm64()

    val xcFramework = XCFramework("SharedLibrary")
    configure(listOf(iosArm64, iosX64, iosSimulatorArm64)) {
        binaries {
            framework {
                isStatic = true
                version = "1.0"
                baseName = "SharedLibrary"
                xcFramework.add(this)
                export("dev.icerock.moko:resources:0.24.2")
                export("dev.icerock.moko:graphics:0.9.0")
            }
        }
    }

    sourceSets {
        commonMain.dependencies {
            api("dev.icerock.moko:resources:0.24.2")
        }
        commonTest.dependencies {
            implementation(libs.kotlin.test)
        }

        iosMain.dependencies{

        }

        androidMain.dependencies {
            
        }

    }
}

android {
    namespace = "com.aliazaz.testkmplibrary"
    compileSdk = 34
    defaultConfig {
        minSdk = 22
    }
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }
    //sourceSets["main"].res.srcDirs("src/commonMain/moko-resources/assets")
    sourceSets["main"].res.srcDirs("build/generated/assets/generateMRandroidMain")
}

multiplatformResources {
    resourcesPackage.set("com.aliazaz.testkmplibrary") // required
}

@AliAzaz
Copy link
Author

AliAzaz commented Sep 11, 2024

@Alex009 please

@AliAzaz
Copy link
Author

AliAzaz commented Sep 12, 2024

@Alex009 @ExNDY any response?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant