In my React Native Android project, I want to use my own library which has a AAR file.
Can someone please guide on how to use the AAR file in my Android build.
Below are my configurations –
- react-native – 0.69.1
- gradle – 7.4.2
- Android Studio Bumblebee – 2021.1.1 Patch 3
- openjdk – "18.0.1.1" 2022-04-22
And I’m getting below error when creating build –
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 :library-name project caused this error**
2
Answers
Use this in "react-native-module-name/android/app/build.gradle":
Copy the .aar files into "react-native-module-name/android/app/libs"
As this solution is not working
You can do this –
Remove the library from /libs and add it using –
Create a new directory and put the following dependencies in build.gradle
Place the .aar file here to next directory, next to build.gradle file
Add the created Gradle project to the settings.gradle –
Include the file into the directory –
Copy the
library.aar
file intoreact-native-module-name/android/app/libs
. Create thelibs
folder if it doesn’t exist.In
react-native-module-name/android/app/build.gradle
: