Android开发拾穗首页投稿(暂停使用,暂停投稿)程序员

一行代码引用library——如何将库上传至jcenter

2016-05-15  本文已影响262人  a57ecf3aaaf2

注册Bintray

点击右上角 获取API KEY

配置Android Studio

classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.6'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
ext {
    bintrayRepo = 'maven'     //仓库名
    bintrayName = 'switch'   //项目名

    publishedGroupId = 'com.fynn.switcher'  //发布id,一般为包名
    artifact = 'switch'     //jcenter的ArtifactId:一般是项目名
    libraryVersion = '1.0.0'    //发布的版本号:每次上传必须不一样

    siteUrl = 'https://github.com/ifynn/Switch'       //网站地址
    gitUrl = 'https://github.com/ifynn/Switch.git'    //git地址

    libraryName = 'switch'       //项目名
    libraryDescription = 'A switch for Android'     //项目描述

    //开发者信息
    developerId = 'Fynn'
    developerName = 'Fynn'
    developerEmail = 'ifynn@outlook.com'

    //版权信息
    licenseName = 'The Apache Software License, Version 2.0'
    licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
    allLicenses = ["Apache-2.0"]
}
apply from: 'https://raw.githubusercontent.com/llxdaxia/GradleScript/master/install_v1.gradle'
apply from: 'https://raw.githubusercontent.com/llxdaxia/GradleScript/master/bintray_v1.gradle'
bintray.apikey=之前记录的api key
bintray.user=bintray用户名
添加用户名及API KEY

执行上传操作

./gradlew bintrayUpload

上传成功
compile 'com.fynn.switcher:switch:1.0.0'
进入详情页申请 `add to JCenter`
可能遇到的问题:
1. Execution failed for task ':appu:bintrayUpload'.
> Could not create package '**': HTTP/1.1 401 Unauthorized [message:This resource requires authentication]
原因:bintray用户名或apikey错误
解决:进入bintray官网查看用户名和apikey,并修改

2.Execution failed for task ':pkg:javadoc'.
> Javadoc generation failed. Generated Javadoc options file (useful for troubleshooting): '.../build/tmp/javadoc/javadoc.options'
原因:若为GBK编码,java源文件中注释不能存在中文
解决:修改编码格式,或者注释中删除中文,或者在项目中添加如下配置,取消javadoc检查:
allprojects {
    repositories {
        jcenter()
    }

    tasks.withType(Javadoc) {
        options.addStringOption('Xdoclint:none', '-quiet')
        options.addStringOption('encoding', 'UTF-8')
    }
}

3.java.lang.UnsupportedClassVersionError: PR/Sort : Unsupported major.minor version 52.0
原因:jdk运行环境和编译环境不匹配
解决:设置JAVA_HOME环境变量、配置Android Studio的jdk路径为与环境变量配置一致的路径
上一篇 下一篇

猜你喜欢

热点阅读