systemProp.http.proxyHost=127.0.0.1 systemProp.http.proxyPort=1080
这样的字段,不知道为什么这个不删掉的话build会出问题,所以如果出了问题吧这个删掉试试repositories {jcenter()}
但是看着容易做着难,走了很多弯路,现在把我的经验分享出来,希望可以帮到别人。//最后写完应该是这样的
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
//主要是下面的两行
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
}
}
allprojects {
repositories {
jcenter()
}
}
//注意,你千万不要将这个文件上传到git,携带隐私信息的
bintray.user=用户名
bintray.apikey=apikey
//在首部添加,是用上传插件,比较重要的是version,他代表你的库的版本,你下次更新时将版本号增加就可以了
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'
version = "1.0.2"
//android{}通常是接着的一部分,这部分没什么变化,但是需要注意的是你的compileSdkVersion如果是23,那么如果使用你的库的人版本是22,他编译会出问题,所以尽可能小一点,不要版本太高了,别人用不了,targetSdkVersion 小一点
android {
//随便写点什么,没有的话不知道碍不碍事,不重要,是资源的前缀符号(自定义控件xml属性时有用)
resourcePrefix "cc_"
compileSdkVersion 22
buildToolsVersion "23.0.2"
defaultConfig {
minSdkVersion 15
targetSdkVersion 15
versionCode 1
versionName "1.0"
}
}
//这个是原始的版本,但是有个问题就是不能打包第三方库,比如android的v7包和其他一些三方,也是网上说的比较多的方法,了解一下,可以不看,在这部分下面是替代的最新方法
//这部分是重点,下面将会使用这些宏,你做的就是需要将下面的信息替换成你自己的
def siteUrl = 'https://github.com/chendongMarch/QuickAdapter' // 项目的主页
def gitUrl = '[email protected]:chendongMarch/QuickAdapter.git' // Git仓库的url
def proName = 'QuickAdapter' //项目的名称,将会显示在bintray
def proDesc = 'quick adapter' //项目的描述,不会有什么影响,随便写点
def yourId = 'chendongmarch' //bintrayID
def yourName = 'chendong' //不重要,你自己的nickname就可以
def yourEmail = '[email protected]' //email
group = "com.march.adapterlibs" // Maven Group ID for the artifact,一般填你唯一的包名
install {
repositories.mavenInstaller {
// This generates POM.xml with proper parameters
pom {
project {
packaging 'aar'
// Add your description here
name proDesc
url siteUrl
// Set your license
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id yourId
name yourName
email yourEmail
}
}
scm {
connection gitUrl
developerConnection gitUrl
url siteUrl
}
}
}
}
}
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}
task javadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives javadocJar
archives sourcesJar
}
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
bintray {
user = properties.getProperty("bintray.user")
key = properties.getProperty("bintray.apikey")
configurations = ['archives']
pkg {
repo = "maven"
name = proName //发布到JCenter上的项目名字
websiteUrl = siteUrl
vcsUrl = gitUrl
licenses = ["Apache-2.0"]
publish = true
}
}
下载build.gradle配置文件
//下面的版本可以打包三方库
def siteUrl = 'https://github.com/chendongMarch/QuickAdapter' // 项目的主页
def gitUrl = '[email protected]:chendongMarch/QuickAdapter.git' // Git仓库的url
def proName = 'QuickAdapter' //项目的名称,将会显示在bintray
def proDesc = 'quick adapter' //项目的描述,不会有什么影响,随便写点
def yourId = 'chendongmarch' //bintrayID
def yourName = 'chendong' //不重要,你自己的nickname就可以
def yourEmail = '[email protected]' //email
group = "com.march.adapterlibs" // Maven Group ID for the artifact,一般填你唯一的包名
install {
repositories.mavenInstaller {
// This generates POM.xml with proper parameters一
pom {
project {
packaging 'aar'
// Add your description here
name proDesc
url siteUrl
// Set your license
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id yourId
name yourName
email yourEmail
}
}
scm {
connection gitUrl
developerConnection gitUrl
url siteUrl
}
}
}
}
}
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}
artifacts {
archives sourcesJar
}
android.libraryVariants.all { variant ->
println variant.javaCompile.classpath.files
if(variant.name == 'release') { //我们只需 release 的 javadoc
task("generate${variant.name.capitalize()}Javadoc", type: Javadoc) {
source = variant.javaCompile.source
classpath = files(variant.javaCompile.classpath.files, project.android.getBootClasspath())
options {
encoding "utf-8"
links "http://docs.oracle.com/javase/7/docs/api/"
linksOffline "http://d.android.com/reference", "${android.sdkDirectory}/docs/reference"
}
exclude '**/BuildConfig.java'
exclude '**/R.java'
}
task("javadoc${variant.name.capitalize()}Jar", type: Jar, dependsOn: "generate${variant.name.capitalize()}Javadoc") {
classifier = 'javadoc'
from tasks.getByName("generate${variant.name.capitalize()}Javadoc").destinationDir
}
artifacts {
archives tasks.getByName("javadoc${variant.name.capitalize()}Jar")
}
}
}
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
bintray {
user = properties.getProperty("bintray.user")
key = properties.getProperty("bintray.apikey")
configurations = ['archives']
pkg {
repo = "maven"
name = proName //发布到JCenter上的项目名字
websiteUrl = siteUrl
vcsUrl = gitUrl
licenses = ["Apache-2.0"]
publish = true
}
}
//在项目名称.gradle文件中添加你bintray的链接
allprojects {
repositories {
jcenter()
maven {url 'https://dl.bintray.com/chendongmarch/maven'}
}
}
//在app.gradle文件中添加
compile 'com.march.adapterlibs:adapterlibs:1.0.2'
allprojects {
repositories {
mavenLocal()
jcenter()
}
}