How are "libs" created and maintained in the gradle android project?

Currently, I do not use the "libs" folder for my third-party dependencies (it seems they are automatically added to create / intermediate / preliminary -dexed /), but noticed that it can help in the analysis of static code, so I would like to add it to project. Note. I am using maven dependencies .

My question is: Are people using their own scripts to create this folder? I almost don't think this is generated once, and then manually maintained when a newer version is available.

Please enlighten me!

0
source share
2 answers

In Android Studio And Gradle, to use the libs folder (except for the old .jar library) is not required .

In fact, you can develop an Android application with Android Studio , as your build.gradle already has an apply plugin: 'com.android.application'

Gralde uses Maven or jCenter via gradle dependencies to import libraries. gradle and Android gradle plugin will automatically load libraries, as you said in the assembly / folder. It is not static and can be cleaned using Clean projet on Android Studio. In addition, Android Studio will add a warning when a new version of the library is automatically available in your build.gradle.

Do not miss the old libs folder used to import the .jar library.

+2
source

Currently, I do not use the "libs" folder for my third-party dependencies (it seems they are automatically added to create / intermediate / preliminary divisions), but noticed that this can help in the analysis of static code, so I would like to add this to the project. Note. I am using maven dependencies.

Do not confuse the libs folder with the build/intermediates/pre-dexed/ .
The gradle plugin for Android currently controls the build process and creates these "internal" and intermediate folders.

My question is: Are people using their own scripts to create this folder? I almost don't think this is generated once

You do not need to create this folder. The Gradle plugin for Android manages it for yours. It will also be deleted and recreated when you run the gradlew clean command.

and then manually when a newer version is available.

No. Your dependencies are defined in the build.gradle file.
When you define a new version, Gradle downloads the new dependency and updates the staging folders.

You can define your dependencies in many ways:

 dependencies{ //You can create a folder and put jar files inside. You can use your favorite name, usually it is libs. compile fileTree(dir: 'libs', include: ['*.jar']) //The support libraries dependencies are in a local maven managed by SDK compile 'com.android.support:appcompat-v7:23.0.0' // A Maven dependency compile 'com.squareup.picasso:picasso:2.5.2' //A local library compile project(':mylibrary') //An aar file. It requires to define a repository. //repositories{ // flatDir{ // dirs 'libs' // } //} compile(name:'nameOfYourAARFileWithoutExtension', ext:'aar') } 
0
source

All Articles