標籤:
http://stackoverflow.com/questions/23077521/where-and-why-add-repositories-on-build-gradle
https://jitpack.io/
1. Add repository in top level gradle file
// Top-level build file where you can add configuration options common to all sub-projects/modules.buildscript { repositories { jcenter() // do not add here } dependencies { classpath ‘com.android.tools.build:gradle:0.12.2‘ // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files }}allprojects { repositories { jcenter() // add repository here maven { url "https://jitpack.io" } }}
2. add dependency to module level gradle file
apply plugin: ‘com.android.application‘android { compileSdkVersion 19 buildToolsVersion "20.0.0" defaultConfig { applicationId "app.tabsample" minSdkVersion 14 targetSdkVersion 14 } buildTypes { release { runProguard false proguardFiles getDefaultProguardFile(‘proguard-android.txt‘), ‘proguard-rules.txt‘ } }}dependencies { compile ‘com.android.support:appcompat-v7:20.0.0‘ // add dependency here compile ‘com.github.PhilJay:MPAndroidChart:v2.1.3‘}
Add a dependency in Android Studio