Reputation: 687
I'm using a react-native
library, and when I'm trying to Rebuild project on Android Studio, I get the below error -
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**
Although I do have aar
file in the android folder of the library I'm using.
I'm using
- react-native - 0.66.4
- gradle version - 6.9
And below is the build.gradle
present in Android folder of library I'm using.
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.2'
}
}
apply plugin: 'com.android.library'
android {
compileSdkVersion 29
defaultConfig {
minSdkVersion 16
targetSdkVersion 29
versionCode 1
versionName "1.0"
}
lintOptions {
abortOnError false
}
}
repositories {
mavenCentral()
google()
flatDir {
dirs 'libs'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.aar'])
implementation 'com.facebook.react:react-native:0.20.1'
}
Below is the picture of library I've mentioned above. In this library, I'm testing it in _test
folder. And _test
is just a normal react-native
project.
And it's the .aar
file inside libs (which is selected in picture) which I've mentioned in above question.
Upvotes: 3
Views: 6959
Reputation: 399
Try following
allprojects {
repositories{
flatDir{
dirs 'libs'
}
}
}
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation files('libs/name-of-the-lib.aar')
Upvotes: 1