Android studio Library项目上传至JCenter

  1. 配置Project目录下build.gradle
 dependencies {        classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'        classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'    }
  1. 注册登录jcenter后
    —>右上角头像处选择View Profile
    —>点击Add New Repository
    —>进入Create Repository页面填写
    —> name(输入仓库名)
    —> Type (选择Maven)
    —>Default Licenses (可选填)(选择Apache-2.0)
    —>Description (可选填)(填写描述)

  2. 在Project目录下的local.properties中配置

bintray.username=bintray.apikey=
    • 注意:
      username:为登录jcenter的用户名 即注册时填写的username,不是邮箱地址
      apikey:获取方式 —>点击顶部右上角头像处—>选择Edit Profile—>选择API Key填写密码后Submit获取
  1. 在Project目录下新建bintray.gradle
apply plugin: 'com.github.dcendents.android-maven'apply plugin: 'com.jfrog.bintray'def siteUrl = 'https://github.com'      // 项目的主页   这个是说明,可随便填,必须能访问def gitUrl = 'https://github.com'      // Git仓库的url  这个是说明,可随便填,必须能访问group = "com.test.mylibrary"    // 这里是groupId ,必须填写  一般填你唯一的包名,对应com.squareup.okhttp3:okhttp:3.4.1中的com.squareup.okhttp3部分version = "1.0.0"//发布到JCenter上的项目版本号android.compileSdkVersion = 28//填当前项目的compileSdkVersioninstall {    repositories.mavenInstaller {        // This generates POM.xml with proper parameters        pom {            project {                packaging 'aar'                // Add your description here                name 'test 测试'     //项目描述                url siteUrl                // Set your license                licenses {                    license {                        name 'The Util Software License, Version 1.0.0'                        url 'http://www.apache.org/licenses/LICENSE-2.0.txt'                    }                }                developers {                    developer {                        id 'hong'        //填写开发者的一些基本信息                        name 'hong'    //填写开发者的一些基本信息                        email '@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) {    options {        encoding "UTF-8"        charSet 'UTF-8'        author true        version true        links "http://docs.oracle.com/javase/7/docs/api"    }    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 {//    userOrg=properties.getProperty("bintray.user")    user = properties.getProperty("bintray.username")    //读取 local.properties 文件里面的 bintray.username    key = properties.getProperty("bintray.apikey")   //读取 local.properties 文件里面的 bintray.apikey    configurations = ['archives']    pkg {        repo = "maven" //需要上传到的仓库名(Repository)对应(Create Repository页面填写的name)        name = "mylibrary"    //发布到JCenter上的项目名字,必须填写,对应com.squareup.okhttp3:okhttp:3.4.1中的okhttp        websiteUrl = siteUrl        vcsUrl = gitUrl        licenses = ["Apache-2.0"]        publish = true    }}
  1. 在需上传的library的build.gradle中配置
apply from: '../bintray.gradle'
  1. 在Terminal中 依次输入
gradlew install

显示BUILD SUCCESSFUL

gradlew bintrayUpload

显示BUILD SUCCESSFUL

  1. 在View Profile页中进入自己建的仓库中
    —>点击进入自己上传的项目
    —>点击Files 查看目录下是否含有xx-javadoc.jar、xx-sources.jar、xx.aar、xx.pom等四个文件(即上传成功)
    —>然后点击Add to JCenter填写信息直接提交

从JCenter中拉取代码

1.直接在app 的build.gradle中添加依赖

implementation 'xxx:1.0.0'
  1. Add to JCenter审核通过之前需要在project 中的build.gradle中配置,审核通过后则无需配置
allprojects {    repositories {        jcenter()        maven {            url "https://dl.bintray.com/username/RepositoryName/" //在所在仓库界面有直接复制即可        }    }}
  • 注:借鉴多人的博客,做个笔记

更多相关文章

  1. Android实战项目:第一行代码CoolWeather
  2. android 项目源码
  3. Cocos项目避免不断复制粘贴android lib库的方法
  4. android studio项目嵌入到Android系统源码
  5. UE4打包Android OpenGLES3格式项目
  6. 如何将android2.1源码添加到自己的项目当中
  7. Android应用程序项目结构
  8. 转 Android之项目推荐使用的第三方库,有助于快速开发,欢迎各位网友

随机推荐

  1. 在某个点停止固定位置滚动?
  2. 使用jquery tablesorter插件,有一个选中项
  3. js是否为空判断大全
  4. 如何使用jQuery选择列表中的最后X项?
  5. jquery为属性过滤器动态添加值?
  6. jQuery Datatable(V1.10.7) server side pr
  7. 如果没有附加,则隐藏本身
  8. 导入地址簿联系人,存储在数组中并保存到数
  9. 绑定和解除相同javascript函数的目的是什
  10. jquery不会对select/选项更改事件作出反