5

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 ?

D.Sachi
  • 51
  • 1
  • 1
  • 2

1 Answers1

2

(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.

LazerBanana
  • 6,865
  • 3
  • 28
  • 47