Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between compile fileTree & Complile jar in Android Studio?

This is not a coding error. this is just about usage of Android studio. I tried to google and find proper solution, but I couldn't.

In an Android studio project there is XYZ.jar file in lib folder. I can use it for compiling as below in gradle.

compile fileTree(include: ['*.jar'], dir: 'libs')

Then I can add same file as dependency also.

File --> Project Structure
Select App from Module
Dependency -> + File dependency

Then Gradle change as below

compile files('libs/XYZ.jar')

What is the difference between these compile fileTree & compile files ?

If we add a jar as a dependency, will it go with generated APK ?

like image 370
D.Sachi Avatar asked Oct 30 '22 05:10

D.Sachi


1 Answers

(Nearly) Everything can be found in Gradledocs

A FileTree represents a hierarchy of files. It extends FileCollection to add hierarchy query and manipulation methods. You typically use a FileTree to represent files to copy or the contents of an archive.

In here you can read about anything you have asked for, including files() and fileTree() https://docs.gradle.org/3.5/javadoc/org/gradle/api/file/FileCollection.html


Summarizing, you can include any .jar artifact from libs directory or a specific artifact to the compile configuration.

like image 106
LazerBanana Avatar answered Nov 10 '22 16:11

LazerBanana