Android发布项目到JCenter遇到的各种坑

坑一:Lint检查

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':testLib:lint'.
> Lint found errors in the project; aborting build.

  Fix the issues identified by lint, or add the following to your build script to proceed with errors:
  ...
  android {
      lintOptions {
          abortOnError false
      }
  }
  ...

Lint 检查默认是开启的,Lint 会检查项目中的语法错误,如果没有通过则无法继续。只需要在 Module 的build.gradle添加如下代码:

android {
    lintOptions {
        abortOnError false
    }
}

坑二:javadoc出错

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':testLib:javadoc'.
> Javadoc generation failed. Generated Javadoc options file (useful for troubleshooting): '/.../javadoc.options'

javadoc出错,在Project的build.gradle加入以下代码:

tasks.getByPath(":testLib:javadoc").enabled = false

坑三:JDK版本

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred evaluating project ':testLib'.
> java.lang.UnsupportedClassVersionError: com/android/build/gradle/LibraryPlugin : Unsupported major.minor version 52.0

造成这个原因是因为jdk版本不一致。根据以下的版本对应关系,下载相对应的jdk 版本即可,版本的对应关系如下:

J2SE 8 = 52,
J2SE 7 = 51,
J2SE 6.0 = 50,
J2SE 5.0 = 49,
JDK 1.4 = 48,
JDK 1.3 = 47,
JDK 1.2 = 46,
JDK 1.1 = 45,

坑四:配置错误

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':testLib:bintrayUpload'.
> Could not create package 'maiml/maven/WxRecoderVideo': HTTP/1.1 404 Not Found [message:Repo 'maven' was not found]

在Bintray中没有找到build.gradle配置的库名

bintray {
    user = properties.getProperty("bintray.user")
    key = properties.getProperty("bintray.apikey")
    configurations = ['archives']
    pkg {
        repo = "maven"  //发布到Bintray的仓库
        name = "WxRecoderVideo"  //发布到Bintray的库名
        desc = "A library look line wechat recoder video"
        websiteUrl = siteUrl
        vcsUrl = gitUrl
        issueTrackerUrl = issueUrl
        licenses = ["Apache-2.0"]
        labels = ["android"]  //标签
        publish = true
        publicDownloadNumbers = true
    }
}

坑五:代理错误

最后一步卡在97%,请检查是否开启了proxy,检查gradle.properties下是否有proxy的信息,将之删除

上一篇 发布开源库到JCenter
下一篇 Android上传项目到JCenter简单步骤
目录
文章列表
1 Linux下MySQL为用户分配指定数据库
Linux下MySQL为用户分配指定数据库
2
数据库优化方案总结
数据库优化方案总结
3
npm及yarn设置和取消代理的方法
npm及yarn设置和取消代理的方法
4
Android 8.0 BroadcastReceiver静态注册大部分取消,动态注册,有序广播
Android 8.0 BroadcastReceiver静态注册大部分取消,动态注册,有序广播
5
Spring Cloud Alibaba集成Sentinel
Spring Cloud Alibaba集成Sentinel
最新评论
一位WordPress评论者
一位WordPress评论者
2月12日
您好,这是一条评论。若需要审核、编辑或删除评论,请访问仪表盘的评论界面。评论者头像来自 Gravatar。