moko-resources icon indicating copy to clipboard operation
moko-resources copied to clipboard

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

Open AliAzaz opened this issue 1 year ago • 2 comments
trafficstars

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 avatar Sep 11 '24 14:09 AliAzaz

@Alex009 please

AliAzaz avatar Sep 11 '24 14:09 AliAzaz

@Alex009 @ExNDY any response?

AliAzaz avatar Sep 12 '24 14:09 AliAzaz