How Is "libs" Created And Maintained In A Gradle Android Project?
Solution 1:
With Android Studio AND Gradle, there is no need to use libs folder (except for old .jar library).
In fact you can develop Android app whitout Android Studio as in your build.gradle there is already a apply plugin: 'com.android.application'
Gralde is using Maven or jCenter via gradle dependencies to import libraries. Gradle and Android Gradle plugin will automaticly download the libs as you sayed in a build/ folder. It is not static and can be clean with the Clean projet
on Android Studio. Also, Android Studio will add a warning when a new library version is available automaticly in your build.gradle.
Dont miss the old libs
folder used to import .jar library
Solution 2:
I currently am not using the "libs" folder for my third party dependencies (it seems they are added automatically to build/intermediates/pre-dexed/) but noticed that it may help static code analysis so I would like to add it to the project. Note: I'm using maven dependencies.
Don't confuse the libs
folder with build/intermediates/pre-dexed/
folder.
Currently the gradle plugin for Android manages the build process and create these "internal" and intermediates folders.
My question: Are people using custom scripts to generate this folder? I hardly think that this is generated once
You don't have to create this folder. The Gradle plugin for Android manage it for your. Also it will be deleted and recreated when your run a gradlew clean
command.
and then manually maintained when there is a newer version available.
No. Your dependencies are defined in your build.gradle
file.
When you define a new version, Gradle downloads the new dependency and updates the intermediate 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')
}
Post a Comment for "How Is "libs" Created And Maintained In A Gradle Android Project?"