Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native [0.66.4][Android] - Direct local .aar file dependencies are not supported when building an AAR

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

  1. react-native - 0.66.4
  2. 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'

}
  

Edit

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.

enter image description here

like image 645
Shubham Bisht Avatar asked Jan 26 '26 11:01

Shubham Bisht


1 Answers

Try following

  1. Place .aar file to android/app/libs directory
  2. Add following code snippet to app build.gradle (just above dependencies for example)
allprojects {
    repositories{
        flatDir{
            dirs 'libs'
        }
    }
}
  1. Add following to app build gradle dependencies:
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation files('libs/name-of-the-lib.aar')
like image 132
alvAro365 Avatar answered Jan 28 '26 02:01

alvAro365



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!