Add a dependency in Android Studio

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‘
}
时间: 2024-09-21 03:24:50

Add a dependency in Android Studio的相关文章

Android问题集锦之四十九:Can't add XStream file dependency to Android Studio project

将xstream1.4.8 引入Android Strudio项目中,编译报错如下: UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dx.cf.iface.ParseException: bad class file magic (cafebabe) or version (0034.0000) at com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:472) at

Android Studio 出现 Gradle's dependency cache may be corrupt 解决方案

将 .\项目地址\gradle\wrapper\gradle-wrapper.properties 文件中的 gradle版本 与 正常的版本 修改一致即可. Android Studio 出现 Gradle's dependency cache may be corrupt 解决方案

Android Studio 新建Andorid工程报错: Conflict with dependency 'com.android.support:support-annotations'

新建Android工程报错: Error:Execution failed for task ':app:preDebugAndroidTestBuild'. > Conflict with dependency 'com.android.support:support-annotations' in project ':app'. Resolved versions for app (26.1.0) and test app (27.1.1) differ. See https://d.and

Android Studio 3.0——unable to resolve dependency for cordovalib

Android Studio 3.0 更新了gradle后,项目竟然开始报错unable to resolve dependency for cordovalib...打开build.gradle看了后其中dependencies是这样写的 dependencies { compile fileTree(dir: 'libs', include: '*.jar') // SUB-PROJECT DEPENDENCIES START debugCompile(project(path: "Cord

Android Studio 简单介绍和使用问题小结

原文  http://www.cnphp6.com/archives/59264 主题 Gradle Android Studio Android 随着android 5.0 的发布,android 开发已经进入了一个全新的时代,eclipse开发安卓已经有点不合时宜了,在github上80%的android项目都采用android studio开发,而且android studio的中文教程越来越多,还有什么理由不固守这eclipse 呢. 下面这篇文章对了解android studio 很有

使用Android Studio自带的NDK编译JNI

/********************************************************************************** * 使用Android Studio自带的NDK编译JNI * 说明: * 省得自己另外去下载NDK,编译JNI,麻烦. * * 2017-4-30 深圳 龙华民治樟坑村 曾剑锋 ****************************************************************************

android studio使用说明

一.学习的基本配置文档,搞好各种参数的基本配置,熟练使用. C:\Program Files\Java\jdk1.7.0_09\bin   二.problems meet in weather android studio: 1.代码不自动补全 解决方法: Files ->Settings-> Editor -> Auto Import 代码报错时,按alt+enter可以自动修改丢失文件.   2.关于android studio的报错信息的具体函数查找 解决方法:看高亮的字体 at

Android NDK and OpenCV Development With Android Studio

Android NDK and OpenCV Development With Android Studio Hujiawei 172 2014年10月22日 发布 推荐 0 推荐 收藏 4 收藏,5.7k 浏览 ---------------- If you do NOT know Chinese, you can just skip this part ---------------- 一直打算将原来的XFace进行改进,最近终于有了些时间可以动手了,改进计划如下:开发上使用Android

Android Studio下构建Maven私服

Android Studio下构建Maven私服 对Maven的理解 Maven仓库的分类 本地Maven仓库和远程Maven仓库(中央仓库,第三方仓库,私服) jcenter和MavenCenter 略 搭建Maven私服 一.下载并安装Maven环境 需要注意的是:后面需要修改Settings setting文件3.0之前在C:\Users\xxx.m2下,其实AndroidStudio通过JCenter下载的jar即放在这个文件夹下.3.0之后在Maven目录的conf下 二.下载并安装N