can anyone tell me which one is suitable for adding a library (jar file only as admob).
If the library is available as an artifact in the Maven or Ivy repository, for example Maven Central, add the repository to the repositories block (for example, mavenCentral() ), and then use compile 'com.android.support:appcompat-v7:+' , replacing the quoted string with one that identifies the artifact you want.
If the library is not available as an artifact, put the JAR in the appropriate directory (e.g. libs/ at the project level) and use compile fileTree(dir: 'libs', include: '*.jar') .
compile project(":libraries:libraryname") is for subprojects that you probably don't have.
compile files('libs/libraryname.jar') works, but compile fileTree(dir: 'libs', include: '*.jar') more flexible since you do not need to change the build.gradle file for each JAR.
CommonsWare
source share