jcenter,maven和grandle

1.jcenter用来作什么?

JCenter is the place to find and share popular Apache Maven packages for use by Maven, Gradle, Ivy, SBT, etc.

jcenter仓库网页地址:https://bintray.com/bintray/jcenter

jcenter仓库源码地址:http://jcenter.bintray.com

可以在"网页地址"中查找到某个库需要的maven/Ivy/gradle依赖形式.

maven仓库网页地址:http://mvnrepository.com/   (maven上能找到的库,在jcenter上都能找到)

maven中央仓库源码地址:http://repo1.maven.org/maven2/

2.android studio 使用国内jcenter和maven镜像地址

由于国内GFW的原因,经常导致Android studio 莫名其妙的编译不了,多数原因是由于不能下载依赖库

Gradle支持三种不同的仓库,分别是:Maven和Ivy以及文件夹。依赖包会在你执行build构建的时候从这些远程仓库下载,当然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:[email protected]‘ //这是一个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.

时间: 2024-08-06 11:58:45

jcenter,maven和grandle的相关文章

jcenter maven 库

先了解compile ‘com.squareup.okhttp:okhttp:2.4.0’的意义 首先我们要了解compile ‘com.squareup.okhttp:okhttp:2.4.0’这一行gradle代码的意义. compile 'com.squareup.okhttp:okhttp:2.4.0 1 基本上我们可以从这一行代码可以了解到,引用一个library的代码需要3个部分,即: GROUP_ID:ARTIFACT_ID:VERSION 在这句代码里面的 GROUP_ID 是c

如何使用Android Studio把library分享到jCenter和Maven Central

原文:How to distribute your own Android library through jCenter and Maven Central from Android Studio 如果你想在Android Studio中引入一个library到你的项目,你只需添加如下的一行代码到模块的build.gradle文件中. 1 2 3 dependencies { compile 'com.inthecheesefactory.thecheeselibrary:fb-like:0.

Android Studio把library分发到jCenter和Maven Central

如果你想在Android Studio中引入一个library到你的项目,你只需添加如下的一行代码到模块的build.gradle文件中. 1 2 3 dependencies { compile 'com.inthecheesefactory.thecheeselibrary:fb-like:0.9.3' } 就是如此简单的一行代码,你就可以使用这个library了. 酷呆了.不过你可能很好奇Android Studio是从哪里得到这个library的.这篇文章将详细讲解这是怎么回事,包括如何

如何使用Android Studio把自己的Android library分享到jCenter和Maven Central

如果你想在Android Studio中引入一个library到你的项目,你只需添加如下的一行代码到模块的build.gradle文件中. 1 2 3 dependencies {     compile 'com.inthecheesefactory.thecheeselibrary:fb-like:0.9.3' } 就是如此简单的一行代码,你就可以使用这个library了. 酷呆了.不过你可能很好奇Android Studio是从哪里得到这个library的.这篇文章将详细讲解这是怎么回事,

[Gradle系列]Gradle发布module库到jcenter, 并构建自己的企业Maven私服

Tamic 作者: http://blog.csdn.net/sk719887916 前言 andorid开发者经常会看到xx公司发布了xx项目,xx公司只提供了gradle配置路径我们就能轻松的使用它们的项目到自己的工程中: 譬如: 谷歌自身的库 compile 'com.android.support:appcompat-v7:22.2.0' 第三方库 compile 'com.squareup.okhttp:okhttp:2.7.2' 很多开发者看过之后羡慕不已, 想自己能不能也写一个自己

How to distribute your own Android library through jCenter and Maven Central from Android Studio

In Android Studio, if you wish to include any library to your application. You could just simply add a following line of dependency in module's build.gradle file. 1 2 3 dependencies {     compile 'com.inthecheesefactory.thecheeselibrary:fb-like:0.9.3

【转】如何使用Android Studio把自己的Android library分发到jCenter和Maven Central

转自:http://www.devtf.cn/?p=760&utm_source=tuicool 如何使用Android Studio把自己的Android library分发到jCenter和Maven Central 原文链接 : How to distribute your own Android library through jCenter and Maven Central from Android Studio 译文出自 : 开发技术前线 www.devtf.cn与 泡在网上的日子

android开源库发布到jcenter图文详解与填坑

相信很多人都用过开源项目,特别是android studio普及以后,使用开源库更方便简单.而如何上传开源库到jcenter供大家方便使用,虽然网上也有教程,但还是遇坑了,最后总结一下,希望可以帮助大家. [csdn地址: http://blog.csdn.net/zhangke3016/article/details/52075159] [本文简书地址: http://www.jianshu.com/p/0acf9e05b27e]同步更新 AndroidStudio是从Maven Reposi

Android Library上传到JCenter仓库实践

前言 这段时间研究了下以前做app开发的时候并没有太过关注的JCenter仓库,在实际开发当中通常都是使用第三方开发者上传到jcenter的library,而我们使用的这些library或者plugin是怎么发布到JCenter并让我使用的? 如果我们想开发一个Library或者plugin,我们该怎么做?带着这些问题,我围绕它做了以下实践: Android Library上传到JCenter仓库实践 Gradle插件开发实践-上传apk文件到Bugly 我会分别以两篇博客来分享一下我的实践过程