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

坑一:Lint检查

1
2
3
4
5
6
7
8
9
10
11
12
13
14
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添加如下代码:

1
2
3
4
5
android {
lintOptions {
abortOnError false
}
}

坑二:javadoc出错

1
2
3
4
5
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加入以下代码:

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

坑三:JDK版本

1
2
3
4
5
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 版本即可,版本的对应关系如下:

1
2
3
4
5
6
7
8
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,

坑四:配置错误

1
2
3
4
5
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配置的库名

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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的信息,将之删除

Powered by AppBlog.CN     浙ICP备14037229号

Copyright © 2012 - 2021 APP开发技术博客 All Rights Reserved.

访客数 : | 访问量 :