首页 > 系统 > Android > 正文

Android快速发布项目到jcenter详解

2019-11-09 17:57:42
字体:
来源:转载
供稿:网友

不管别人的教程多详细,都有他们忽略的坑,所以,都要自己动手。我也是参考了许多许多的博客,弄了一上午加下午十分钟,才搞定。

参考: 下面这个是大部分的步骤 http://blog.csdn.net/zhcswlp0625/article/details/54895584

下面这个是填坑的: http://blog.csdn.net/tmac2000/article/details/53261141

坑一: 创建仓库时,如果使用Bintray-release,名字就填成maven,因为他的wiki:repoName: The repository name. Set to ‘maven’ by default.(有错误请指出) 不然就会报错: Bintray- HTTP/1.1 404 Not Found [message:Repo ‘maven’ was not found]

坑二:gradle版本号要写为: classpath ‘com.android.tools.build:gradle:2.1.0’ 因为 classpath ‘com.android.tools.build:gradle:2.2.0’ 好像会报unsupport * 错误

我自己的一些配置: 最外层的grale配置:

// Top-level build file where you can add configuration options common to all sub-PRojects/modules.buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.1.0' classpath 'com.novoda:bintray-release:0.3.4' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files }}allprojects { repositories { jcenter() }}task clean(type: Delete) { delete rootProject.buildDir}

要上传的gradle配置:

apply plugin: 'com.android.library'apply plugin: 'com.novoda.bintray-release'//添加android { compileSdkVersion 23 buildToolsVersion '23.0.0' defaultConfig { minSdkVersion 15 targetSdkVersion 23 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } lintOptions { abortOnError false }}dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) compile 'com.android.support:appcompat-v7:25.0.0' testCompile 'junit:junit:4.12'}publish { userOrg = 'coaxinyu'//bintray.com用户名 groupId = 'com.caoxinyu'//jcenter上的路径 artifactId = 'coaxinyu'//项目名称 publishVersion = '1.0.0'//版本号 desc = 'this is for test'//描述,不重要 website = 'https://github.com/coaxinyu/tobebetter'//网站,最好有,不重要}

然后执行的命令:

gradlew clean build bintrayUpload -PbintrayUser=coaxinyu -PbintrayKey=***** -PdryRun=false

记住,学东西都要自己动手,别人的教程再详细,在你的电脑上都会有坑。记住了,年轻人,自己动手。


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表