https://kotlinlang.org logo
#compose
Title
# compose
r

Roberto Leinardi

05/14/2022, 10:11 PM
I've more or less finished porting my FloatingActionButtonSpeedDial library to Compose and I'm now in the process of publishing it to maven central but, when I generate the AAR, I can't understand why, all the composable classes throw an
Unresolved reference
. The crazy thing is that the the enum on the same package is perfectly fine. And so is the AAR of the classic view library. And of course the issue does not happen if I import the gradle module directly instead of using the AAR. Do I need to do something special to generate an AAR with Composable? build.gradle of the library module
I really don't get it, the classes seem to be there:
t

tad

05/14/2022, 10:31 PM
They aren't there, actually. The
*Kt.class
files are just the top-level declarations from the .kt file, not the classes that are missing from that import list.
r

Roberto Leinardi

05/14/2022, 10:33 PM
I said classes but it's not a class, it's just a composable annotated function, and it's there, or am I missing something?
t

tad

05/14/2022, 10:35 PM
Ah, okay. That's strange, I'm not sure why they would be stripped from the AAR.
r

Roberto Leinardi

05/14/2022, 10:37 PM
I really don't know what else to try, I went on github and checked a bunch of different compose libraries and I can't find anything special inside the build.gradle... It's so frustrating: after all the effort to port the library now I'm blocked by this weird bug...
t

tad

05/14/2022, 10:47 PM
One thing that gives me pause is setting
targetSdkVersion
for a library project; usually you specify a
minSdkVersion
and let the consuming application set the target, otherwise there are some arcane rules used by the manifest merger
You appear to be excluding the consumer-proguard rules as well
And
*.kotlin_module
which would probably explain why the top-level functions aren't being resolved
1
Where did that config come from? I would clear out
packagingOptions
and only add what's necessary to get the project to build
👍 1
l

Leland Richardson [G]

05/14/2022, 11:30 PM
you might want to ensure that the module you are calling them from is using the Compose Compiler
a

Albert Chang

05/15/2022, 3:12 AM
I can't tell from the build script but yes this looks like the symptom when you strip out
META-INF/<module name>.kotlin_module
from the aar. That file is needed to access top-level members.
1
r

Roberto Leinardi

05/15/2022, 8:06 AM
@tad thank you for the suggestions.
targetSdkVersion
set for all the modules via build conventions
oh wow! The
packagingOptions
exclusion list was causing the problem! I don't remember from where I took that list but it never occurred that could have these side effects on AAR (I'm using it for months on a couple of apps without issue). But yeah, from now on I'll drop it and just manually add only what's needed. Thanks a lot!
Compose version releases 🙂 Here a quick and dirty video comparison: https://imgur.com/a/BtUU2Qx
4 Views