Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using flatDirs should be avoided because it doesn't support any meta-data formats

I'm seeing the following warning when building in Android Studio:

Using flatDirs should be avoided because it doesn't support any meta-data formats

enter image description here

I'm integrating with an aar that is packaged locally in my libs directory. Is there another way to integrate without adding the following problematic block to my build.gradle?

repositories {
    flatDir {
        dirs 'libs'
    }
}
like image 282
Adam Johns Avatar asked Jul 01 '21 18:07

Adam Johns


People also ask

What is flatDir in Gradle?

repositories { flatDir { dirs("lib") } flatDir { dirs("lib1", "lib2") } } This adds repositories which look into one or more directories for finding dependencies. This type of repository does not support any meta-data formats like Ivy XML or Maven POM files.

What is dependencyResolutionManagement?

The dependencyResolutionManagement repositories block accepts the same notations as in a project, which includes Maven or Ivy repositories, with or without credentials, etc. By default, repositories declared by a project will override whatever is declared in settings.

What is the command to check Gradle version?

In the command prompt, enter Gradle -version. It will display the current version of Gradle just installed on the screen.


1 Answers

Add following piece of code in android block:

android { ..
 sourceSets {
        main {
            jniLibs.srcDirs = ['libs']
        }
    }
}

and add dependency as:

implementation (files("libs/test_name.aar"))

delete following block:

repositories {
    flatDir {
        dirs 'libs'
    }
}
like image 116
Usman Rana Avatar answered Sep 18 '22 16:09

Usman Rana