Issue
I am working on an Android library that will contain different screens inside an activity. I initially wanted to use Compose for the UI, but I encountered a problem with this approach. In my module, I need to set Compose options with kotlinCompilerExtensionVersion. This version should match the specific Kotlin plugin version of the app that will use my library. However, in different apps, this version can vary. Are there any ways to solve this, or is using XML views the way to go?
Solution
The kotlinCompilerExtensionVersion
only has to match if you compile your library with your project. Meaning if you include your library as a module with something like implementation(project(':yourlibrary'))
and then build your app.
However if you distribute your library as a precompiled aar, for example with a maven repository, it is already compiled into an .aar and therefore the kotlinCompilerExtensionVersion
doesn't really matter. Then every project can import it via the usual gradle dsl: implementation('your:lib:1.0.0)
You can easily test this by making a new project and add your .aar library as a file. Or publish your library to your local maven repository with the Gradle Maven publish plugin. Just add it to your gradle, with something like
publishing {
publications {
release(MavenPublication) {
groupId = 'com.my-company'
artifactId = 'my-library'
version = '1.0'
afterEvaluate {
from components.release
}
}
}
}
and then run ./gradlw publishToMavenLocal
Also see the official docs about publishing an Android library for more information.
Answered By - Stephan
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.