Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unresolved reference when using a generated AAR with Composables

I'm in the process of porting my FloatingActionButtonSpeedDial library to Compose and I've reached the step where I should publish the new Compose library to maven central but, when I generate the AAR, all the composable classes throw an Unresolved reference.

enter image description here

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. So, the issue seems to affect only functions annotated with @Composable.

The issue happens with both a debug and release AAR so should not depend on minimization on release.

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?

This is build.gradle of the library module

like image 871
Roberto Leinardi Avatar asked Oct 20 '25 11:10

Roberto Leinardi


2 Answers

The issue is caused by the packagingOptions:

    packagingOptions {
        resources {
            exclude '.readme'
            exclude 'LICENSE.txt'
            exclude 'fabric/*.properties'
            // Exclude the Firebase/Fabric/other random properties files
            exclude '/*.properties'
            // Exclude AndroidX version files
            exclude 'META-INF/*.version'
            // Exclude consumer proguard files
            exclude 'META-INF/proguard/*'
            exclude 'META-INF/*.properties'
            exclude 'META-INF/LICENSE.txt'
            exclude 'META-INF/MANIFEST.MF'
            exclude 'META-INF/NOTICE.txt'
            exclude "META-INF/AL2.0"
            exclude "META-INF/LGPL2.1"
            exclude 'META-INF/maven/com.google.guava/guava/pom.properties'
            exclude 'META-INF/maven/com.google.guava/guava/pom.xml'
            exclude 'META-INF/*.kotlin_module'
            // for byte-buddy
            exclude "META-INF/licenses/ASM"
            pickFirst "win32-x86-64/attach_hotspot_windows.dll"
            pickFirst "win32-x86/attach_hotspot_windows.dll"
        }
    }

And, in particular by the exclude 'META-INF/*.kotlin_module': this file is needed to access top-level members, so don't exclude it.

It would be better clear this exclusion list and only add what's necessary to get the project to build.

like image 181
Roberto Leinardi Avatar answered Oct 23 '25 06:10

Roberto Leinardi


The scope of these classes seems to be package private, compared to class SpeedDialState. Maybe take a look at other composable libraries, in order to see how they do it:
https://github.com/jetpack-compose/jetpack-compose-awesome#libraries

like image 33
Martin Zeitler Avatar answered Oct 23 '25 08:10

Martin Zeitler



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!