Skip to content

Direct local .aar file dependencies are not supported when building an AAR.

Snoy-Kuo edited this page Mar 29, 2022 · 1 revision

Messages

Direct local .aar file dependencies are not supported when building an AAR. The resulting AAR would be broken because the classes and Android resources from any local .aar file dependencies would not be packaged in the resulting AAR. Previous versions of the Android Gradle Plugin produce broken AARs in this case too (despite not throwing this error). The following direct local .aar file dependencies of the :ocr project caused this error: /project_path/someModule/someLib.aar

Description

When add a AAR file in a library module, you can debug and run App normally. But if you want to build release version. Uh-oh, building failed.

Dev env

  • macOS 12.2.1 (Monterey) x64
  • Android Studio Bumblebee Patch 1
  • Android SDK version 31
  • Android Gradle Plugin: 7.0.4
  • Gradle: 7.1.1
  • Gradle JDK: 11
  • Kotlin: 1.6.10

Tried approaches

Solutions

  • Android library 依赖 aar 包的两种方式
    • create a module(eg. aars-module) with a build.gradle and the AAR files.
    • add these lines to the build.gradle file:
       configurations.maybeCreate("default")
       artifacts.add("default", file('someLib.aar'))
      
    • add inclue ':aars-module' to the settings.gradle file.
    • add api project(:aars-module) or implementation project(:aars-module) to the build.gradle file of which module using the AAR files' feature.