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的信息,将之删除

版权声明:
作者:Joe.Ye
链接:https://www.appblog.cn/index.php/2023/03/29/various-pitfalls-encountered-when-releasing-android-projects-to-jcenter/
来源:APP全栈技术分享
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
打赏
海报
Android发布项目到JCenter遇到的各种坑
坑一:Lint检查 FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':testLib:lint'. > Lint found errors……
<<上一篇
下一篇>>
文章目录
关闭
目 录