It's not 100% related to Compose but still - proba...
# compose
z
It's not 100% related to Compose but still - probably a good place to ask. I started implementing our internal design system in Compose and I published it to Maven Local. Then I wanted to use it in another project, but I'm not able to call any "global" functions - e.g. I have a file called
OneButton
with a single method in it (no classes or objects):
Copy code
@Composable
fun OneButton(
    modifier: Modifier = Modifier
...
If I try to call it from my other project, Android Studio does not recognize the function. Then I decided to experiment and created a dummy Kotlin class with a single
@Composable
method in it. Published the .aar to Maven Local and used it in the other project. I created an instance of the dummy class and successfully called the
@Composable
function. What am I missing - my setup is more or less the same as in Accompanist (I'm not using Metalava and/or API file), I'm using the same Gradle plugin for publishing the artefacts... Any idea what may be wrong?
3
🧵 1
l
Do you exclude any files from
packagingOptions
in the library
build.gradle(.kts)
file?
z
Hmm haven't thought about that. Quite a few, all part of
META-INF
directory:
Copy code
packagingOptions {
        resources.excludes.add("META-INF/DEPENDENCIES")
        resources.excludes.add("META-INF/LICENSE")
        resources.excludes.add("META-INF/LICENSE.txt")
        resources.excludes.add("META-INF/license.txt")
        resources.excludes.add("META-INF/NOTICE")
        resources.excludes.add("META-INF/NOTICE.txt")
        resources.excludes.add("META-INF/notice.txt")
        resources.excludes.add("META-INF/AL2.0")
        resources.excludes.add("META-INF/ASL2.0")
        resources.excludes.add("META-INF/LGPL2.1")
        resources.excludes.add("META-INF/*.kotlin_module")
    }
l
The last one should be applied only to apps.
👍 2
This is the root cause of your issue.
Without that, you'll see it like a compiled java library.
z
Yep.. it's working now. Thanks a lot for the help! I've added those excludes at some point as I was having troubles (the usual error message about them). I'll read more about
*.kotlin_module
files 🙂
If someone finds this post - this SO answer provides info about
*.kotlin_module
files and their purpose
👍 2