1.jcenter用来做什么?html
JCenter is the place to find and share popular Apache Maven packages for use by Maven, Gradle, Ivy, SBT, etc. java
jcenter仓库网页地址:https://bintray.com/bintray/jcenterandroid
jcenter仓库源码地址:http://jcenter.bintray.com git
能够在"网页地址"中查找到某个库须要的maven/Ivy/gradle依赖形式.github
maven仓库网页地址:http://mvnrepository.com/ (maven上能找到的库,在jcenter上都能找到)缓存
maven中央仓库源码地址:http://repo1.maven.org/maven2/app
2.android studio 使用国内jcenter和maven镜像地址maven
因为国内GFW的缘由,常常致使Android studio 莫名其妙的编译不了,多数缘由是因为不能下载依赖库ide
Gradle支持三种不一样的仓库,分别是:Maven和Ivy以及文件夹。依赖包会在你执行build构建的时候从这些远程仓库下载,固然Gradle会为你在本地保留缓存,因此一个特定版本的依赖包只须要下载一次。gradle
repositories {
mavenCentral()
jcenter() //默认的jcenter中央仓库http://jcenter.bintray.com
mavenLocal()
}
为了不因为被墙,咱们使用国内mave库,这里使用的是开源中国的maven库开源中国maven网页、连接镜像地址:http://maven.oschina.net/home.html
咱们在studio中只需替换项目根目录下build.gradle中的jCenter或者maven就好
allprojects {
repositories {
maven{ url 'http://maven.oschina.net/content/groups/public/'} //如下的库具备优先级
mavenCentral()
jcenter() //默认的jcenter中央仓库http://jcenter.bintray.com
mavenLocal()
}
}
3.gradle依赖
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0' //表示android使用的gradle的的插件,须要与studio的版本匹配
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs') //表示依赖的包 :libs,目录下全部的.jar包
compile 'com.android.support:recyclerview-v7:23.3.0' //这是一个本地sdk中的包
compile 'com.google.android.gms:play-services-appindexing:8.4.0' //这是一个本地sdk中的包
compile 'com.github.lecho:hellocharts-library:1.5.8@aar' //这是一个jcenter中的包,能够在jcenter或mavenCentral中查到
compile 'org.greenrobot:eventbus:3.0.0' //这是一个jcenter中的包,能够在jcenter或mavenCentral中查到
}
Error:Error converting bytecode to dex:
Cause: Dex cannot parse version 52 byte code.
This is caused by library dependencies that have been compiled using Java 8 or above.
If you are using the 'java' gradle plugin in a library submodule add
targetCompatibility = '1.7'
sourceCompatibility = '1.7'
to that submodule's build.gradle file.