Home > Net >  Unresolved reference when using a generated an AAR with Composables
Unresolved reference when using a generated an AAR with Composables

Time:05-16

I'm in the process of porting my 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

CodePudding user response:

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

CodePudding user response:

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.

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

  • Related