Android Studio上传项目到jcenter
来源:互联网 发布:非线性优化算法面试题 编辑:程序博客网 时间:2024/05/04 06:56
现在我们使用Android Studio进行开发,当需要使用到第三方库的时候,通常情况下我们会在gradle文件中的依赖里边添加一句话 “compile xxx.xxx.xxx:xxx:1.0.0”,就可以非常方便的将别人的库引入到自己的项目中,今天我们就来和大家一起将自己写的代码上传到jcenter中,供别人调用。
首先,我们需要到bintray中注册一个账号。
注册好之后,我们到用户中心去获取API Key,一会要用到,如图所示:
获取到API Key之后,我们去配置我们的library,在项目的build.gradle中添加如下代码:
buildscript { repositories { jcenter() mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:2.2.2' classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files }}
同时,在library的build.gradle中添加如下代码:
apply plugin: 'com.jfrog.bintray'apply plugin: 'com.github.dcendents.android-maven'def siteUrl = 'xxx' // 项目的主页 一般填你项目的github地址即可def gitUrl = 'xxx.git' // Git仓库的url 填你项目的git地址group = "com.gitzzp.bpb" // Maven Group ID for the artifact,一般填你唯一的包名version = "1.0.0"//项目版本号install { repositories.mavenInstaller { // This generates POM.xml with proper parameters pom { project { packaging 'aar' // Add your description here name 'test jcenter' //项目描述 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 'gitzzp' //填写一些开发者的基本信息 name 'zhangzhipeng' email 'gitzzp123@gmail.com' } } 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" //仓库名字 repository name = "gitzzptest" //发布到JCenter上的项目名字 package userOrg = 'gitzzp9' //组织名称 organization //上边三个可自由填写 但是一定要和bintray账号中我们添加的组织、仓库、包名对应上,否则肯定上传失败 一会我们去bintray中添加这几项。 websiteUrl = siteUrl vcsUrl = gitUrl licenses = ["Apache-2.0"] publish = true }}
在项目的local.properties文件中添加如下代码:
bintray.user=gitzzp123 //你的bintray用户名bintray.apikey=*** //我们刚才从bintray中获取的API Key
library我们已经配置完成,现在我们回头去bintray中创建组织、仓库和包,在我们bintray的个人主页中依次创建组织,如图所示:
这里有几个需要注意的问题,repositories的名称是可以随便填的,但是类型要选maven,package创建的时候,注意licenses和version control就可以了。
都创建好之后,将几个名称一一对应的填到我们library对应的位置即可。
然后,我们来上传libray,在Android Studio中打开命令行,分别运行如下命令,即可成功上传:
./gradlew install./gradlew bintrayUpload
注:
1.如果是windows系统,将前边“./”去掉。
2.如果出现404的问题,一般是你的某种信息没有对应上,仔细检查即可,千万注意组织、仓库和包这几个位置。
上边红线的位置,依次对应的就是组织,仓库和包名,可以在浏览器中进行验证:https://bintray.com/加上红线标注的内容。
最后,我们将上传成功的libray发布到jcenter中,在package页面中的右下角位置可以找到按钮,如图所示:
然后坐等审核通过,就可以使用了。
- Android Studio上传项目到jcenter
- Android Studio上传项目作为lib到jcenter中
- Mac Android Studio将项目(library)上传到jcenter
- Android Studio 项目上传到Jcenter完全攻略
- Android Studio使用Gradle上传到jCenter
- android studio module上传到jcenter
- Android Studio 将Library 上传到 Jcenter
- Android Studio 上传aar(Library)到JCenter
- Android Studio上传项目至jCenter
- Android Studio发布项目到Jcenter
- Android Studio发布项目到Jcenter
- 使用Android studio发布项目到jcenter
- Android Studio发布项目到Bintray jCenter
- Android Studio发布项目到jCenter
- Android Studio 发布项目到Jcenter
- Android Studio发布项目到Jcenter
- 上传项目到jcenter
- Android Studio中快速将Library上传到JCenter
- set-env.bat
- 简易秒表
- ASP.NET Core MVC-WebAPi如何构建路由?
- 【Java】Java编译错误:需要class,interface或enum
- 传说
- Android Studio上传项目到jcenter
- Bootstrap分页插件--Bootstrap Paginator---使用方法 -3三个属性(type, page, current))
- PAT---B1009. 说反话 (20)
- 在Tomcat中手动部署servlet
- ASP.NET MVC with Entity Framework and CSS一书翻译系列文章之第六章:管理产品图片——多对多关系(上篇)
- 微信小程序Form通知
- SSH网上商城--准备工作
- DNS
- Android调试偶现bug的方法