I am having trouble using koin in my library, when...
# library-development
z
I am having trouble using koin in my library, when i try to use my library in a sample app i get an error saying
java.lang.NoClassDefFoundError: Failed resolution of: Lorg/koin/core/component/KoinComponent;
my library module gradle uses koin with version control
Copy code
implementation(libs.koin.android)
i publish the module to an aar and i included koin in my proguard rules
Copy code
-keep class org.koin.core.** { *; }
-keep interface org.koin.core.** { *; }
Is it problematic to use dependencies in my library? i dont want the consuming app to know about my internal use of koin, they may be using any or no DI in their app
I tried removing koin and wrote my own service locator and gor the same error on okhttp3 so its not about koin, i gues i am publishig or building the library wrong:
Copy code
publishing {
    publications {
        println("Available components:")
        project(":core").components.forEach {
            println(it.name)
        }
        create<MavenPublication>("release") {
            artifact("$buildDir/outputs/aar/${project.name}-release.aar")
            groupId = "com.onestep.android"
            artifactId = "core"
            version = project.extra["baseVersionName"] as String
        }
    }
    repositories {
        maven {
            url = uri("${project.buildDir}/repo")
        }
    }
}
My issue is resolved by adding the
pom
block to my publishing script on
gradle.build.kts
Copy code
pom {
                                    withXml {
                    val dependenciesNode = asNode().appendNode("dependencies")
                    configurations["api"].allDependencies.forEach {
                        val dependencyNode = dependenciesNode.appendNode("dependency")
                        dependencyNode.appendNode("groupId", it.group)
                        dependencyNode.appendNode("artifactId", it.name)
                        dependencyNode.appendNode("version", it.version)
                        dependencyNode.appendNode("scope", "compile") // "compile" for API, "runtime" for implementation
                    }
                }
            }
127 Views