[Solved] Direct local .aar file dependencies are not supported when building an AAR. Gradle upgrade to version 4.0 and above

error message:

* What went wrong:
Execution failed for task ':AliPlayer:bundleReleaseAar'.
> 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 depen
dencies 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 :AliPlayer project caused this error: E:\CODE\XXXXXXXXr\libs\AliyunPlayer-5.4.1-full.aar

Reason: Problems occurred when building packages when upgrading gradle to version 4.0 or above.

I searched Baidu online and read various blogs.
The solutions vary, but I followed the steps mentioned online and the problem still exists.
List them

api fileTree(include: ['*.aar', '*.jar'], exclude: [], dir: 'libs')

There is this kind of thing:

implementation files('libs\\:XXXXX.aar');

There is also this:

implementation('XXXXXXX.aar')

There is this kind of thing:

implementation(name: 'XXXX', ext: 'aar')'

Another one is:
1. In the root directory, New -> New Module -> Import .JAR/.AAR Package, named subAar, and then import your aar file,
Finally, click finish and the creation is successful. There are three files in the subAar directory: build file; one is an aar file; build.gradle, where the build.gradle file is the statement of the referenced aar file, which contains the following

`configurations.maybeCreate("default")
artifacts.add("default", file('XXXX.aar'))`

Reference it in the library module build.gradle file:

implementation project(":subAar")

2.Introduce in settings.gradle:

include ':subAar'

Then the build will be successful,

But, because there are multiple aar files in the actual project, there are also introductions on the Internet that the last form can have multiple aar files. After I tried it, it still didn’t work, so I continued to Baidu.
Finally found a form based on the last method
1. In the root directory, New -> New Module -> Import .JAR/.AAR Package, named subAar1, and then import your aar file,
Finally click finish and the creation is successful. Then create as many Import .JAR/.AAR Package type Modules in the root directory based on how many aar files there are.
2. Then create a file named LocalRepo in the root directory, and move the created Import .JAR/.AAR Package type Module to the LocalRepo file.
3. Reference in the project

api project(path: ':LocalRepo:AarModule1r')
    api project(path: ':LocalRepo:AarModule2')

4.Introduced in settings.gradle:

include ':LocalRepo:AarModule1'
include ':LocalRepo:AarModule2'

As shown in the picture:

In this way, the package can be built successfully and recorded.

Related Posts

Overwriting the repositories warehouse address in gradle in Flutter and Android

Android set background color transparency

Use ADB to batch install apk

Unity exports the Android project and creates a new activity to place the privacy agreement

Dialog of Getx series

IDEA background interacts with Android data

Teach you step by step how to make the navigation bar at the bottom of your mobile phone, and your boss will agree after reading it

Installing third-party firmware on x3-55 letv (by quqi99)

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

*