简单上传项目到jcenter

将一些base ,utils 上传到jcenter

感谢
Android 快速发布开源项目到jcenter
如何让别人在gradle中直接compile你的开源库

  1. 创建Project,创建android library
  2. 注册bintray.com 获得API Key
  3. Projectbuild.gradle 下的dependencies 添加classpath 'com.novoda:bintray-release:0.5.0'
buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.0'//具体看你本地版本
       // https://github.com/novoda/bintray-release 最新版本可以在这里查看 (注意和gradle版本统一)
        classpath 'com.novoda:bintray-release:0.4.0'
    }
}
  1. librarybuild.gradle下添加apply plugin: 'com.novoda.bintray-release' 以及publish
apply plugin: 'com.android.library'
apply plugin: 'com.novoda.bintray-release'//上传到jcenter工具

  android {
  //...
  }

  publish {
      userOrg = 'pdog18'    //bintray.com用户名
      groupId = 'com.pdoglog'    //jcenter上的路径
      artifactId = 'pdoglog'    //自己的maven上添加的包名
      publishVersion = '0.0.1'    //版本号
      desc = 'desc...'    //描述
      website = 'https://github.com/pdog18'    //网站,不重要;
  }
  dependencies {
  //..
  }

5.命令行输入
gradlew clean build bintrayUpload -PbintrayUser=username -PbintrayKey=APIKey -PdryRun=false
Mac系统 前面是./gradlew
将命令行中的username 换成你的用户名,APIKey换成第二步获得的key

  1. bintray Add to JCenter

遇到的问题:

  1. add to JCenter 的时候提示 Empty packages are not allowed in JCenter. 无法提交项目,
    查看Files 的确是没有任何文件There are no files yet for this package.
    查看命令行: :bintrayUpload: Could not find publication: release.
    向上查看日志
WARNING: Gradle 2.14.1 not supported by bintray-release plugin. Update required!
The bintray-release plugin doesn't support version of Gradle below 3.4 for Android libraries. Please upgrade to Gradle 3.4 or later.
The last bintray-release plugin supporting Gradle 3.3 is 'com.novoda:bintray-release:4.0'
Upgrade Gradle:
./gradlew wrapper --gradle-version 3.5 --distribution-type all
The bintray-release plugin can't create a Publication for your Android Library with Gradle 2.14.1!

提示我的bintray-release版本和gradle版本不统一,将bintray-release 改为0.4.0

  1. 遇到中文注释乱码问题
//错误日志类似这样
D:\Jcenter\plog\src\main\java\com\pdog\plog\logtype\JsonLog.java:35: 错误: 编码GBK的不可映射字符 Log.d(tag, "鈺? " + line);       

Project下的build.gradle下添加

allprojects {
    repositories {
        jcenter()
    }

    allprojects {
        tasks.withType(JavaCompile) {    //设置全局编码
            options.encoding = "UTF-8"
        }
        tasks.withType(Javadoc) {  //设置文档编码
            options {
                encoding "UTF-8"
                charSet 'UTF-8'
                links "http://docs.oracle.com/javase/7/docs/api"
            }
        }
    }
}
  1. 成功add JCenter 但是不能拉取
Error:(34, 13) Failed to resolve: com.pdoglog:pdoglog:0.0.2
Show in File
Show in Project Structure dialog
  1. 确认在Projectallproject节点下,添加了maven { url "https://jitpack.io" }
allprojects {
    repositories {
        jcenter()
        maven { url "https://jitpack.io" }
    }  
}
  1. 依然无法拉取,第二天上班的时候来,什么也没做就ok了。 也许是审核问题,以收到bintray 的站内信为准

你可能感兴趣的:(简单上传项目到jcenter)