This article uses ‘com.novoda:bintray-release ‘as an upload plug-in. The following uses my personal Utils Library upload as an example:
Sign up for bintray
Address: bintray.com/signup/oss
Note: Bintray can be registered through Github, Google and Twitter
Create the Bintray repository
Address: bintray.com/profile/edi…
Operation steps:
- Click on the “Repositories” option on the left,
- Click the “New Repository” button to the right of this option,
- Fill in the Name box with the value “maven”,
- Select the value of the Type option box as “Maven”,
- Click the “Create” button.
Note: The value maven for the Name box must be lowercase.
Configure gradle parameters
Configuration gradle – wrapper. Properties
#Sun May 21 20:41:27 CST 2017distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME ZipStorePath = wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip // Could not generate a proxy classforThe class com. Android. Build. Gradle. Tasks. BuildArtifactReportTask. ` such errorsCopy the code
Configure Project build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com. Android. Tools. Build: gradle: 3.0.0'// Could not generate a proxy classforThe class com. Android. Build. Gradle. Tasks. BuildArtifactReportTask. ` such errors / / NOTE: Do not place your application dependencies here; they belong //in the individual module build.gradle files
classpath 'com.novoda:bintray-release:+'}} AllProjects {repositories {jCenter ()} tasks. WithType (Javadoc) {// New options. AddStringOption ()'Xdoclint:none'.'-quiet')
options.addStringOption('encoding'.'UTF-8')
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Copy the code
Configure build.gradle for the Library project
apply plugin: 'com.android.library'
apply plugin: 'com.novoda.bintray-release' // 新增
android {
...
lintOptions { // 新增
abortOnError false
}
}
dependencies {
...
}
publish { // 新增
userOrg = 'fqxyi'// Register bintray username groupId ='com.fqxyi'// Project package name artifactId ='utils'// Project name publishVersion ='1.0.0'// Release version desc ='Summarize the tools or methods commonly used in routine development'// Project description, optional website ='https://github.com/fengqingxiuyi/AndroidUtils'// Project site, optional}Copy the code
Configure build.gradle for other modules
. android { ... LintOptions {// Add abortOnErrorfalse}}...Copy the code
Executing the upload command
Command:
gradlew clean build bintrayUpload -PbintrayUser=username -PbintrayKey=API Key -PdryRun=false
Copy the code
Command explanation:
- The value of PbintrayUser is username when bintray was registered.
- The value of PbintrayKey is the BINtray Api Key, available fromBintray.com/profile/edi…To the left of the url
API Key
In the choices, - PdryRun is a configuration parameter that, when true, means that all links are run but no uploads.
Apply to add to JCenter
Address: bintray.com/username/ma…
Note:
- The username in the url needs to be changed to the username when registering bintray.
- The artifactId in the url needs to be replaced with the project name.
Operation steps:
- Click the “Add to JCenter” button in the lower right corner to Add library Package to jCenter, which will take you to bintray.com/message/add… Url,
- Click the “Send” button to Send the request.
Check whether the application is approved
Visit jcenter.bintray.com/groupId/art… If you can see the following four files, your application will be approved:
artifactId-publishVersion-javadoc.jar
artifactId-publishVersion-sources.jar
artifactId-publishVersion.aar
artifactId-publishVersion.pom
Copy the code
Note: The groupId in the url, which defaults to the project package name, needs to be changed after it becomes part of the url. Symbol to/symbol, for example: https://jcenter.bintray.com/com/fqxyi/utils/utils/1.0.0/
FAQ
Repo ‘maven’ was not found
Question:
* What went wrong:
Execution failed for task ':androidutilslibrary:bintrayUpload'.
> Could not create package 'fqxyi/maven/androidutilslibrary': HTTP/1.1 404 Not Found [message:Repo 'maven' was not found]
Copy the code
Solution: Repository not created or repository name incorrectly written. Note that maven is lowercase
Lint checks an error
Problem: Lint checks fail, causing Build & Upload to fail
Solution:
Method 1: You need to correct the Error level problems according to the Error information.
Option 2: Configure the following Lint option implementation for the Library project build.gradle — this option is taken from the network and not verified:
android {
...
lintOptions {
abortOnError false // Do not stop packing even if an error is reported
checkReleaseBuilds false // Release versions are packaged without Lint detection}... }Copy the code
The upload failed due to a network problem. Procedure
Question:
* What went wrong:
Execution failed for task ':utils:bintrayUpload'.
> javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated
Copy the code
* What went wrong:
Execution failed for task ':utils:bintrayUpload'. > org. Apache. HTTP. Conn. HttpHostConnectException: Connection refused to http://127.0.0.1:8888Copy the code
* What went wrong:
Execution failed for task ':utils:bintrayUpload'.
> org.apache.http.NoHttpResponseException: The target server failed to respond
Copy the code
Solution:
Step 1: Close the proxy software and restart the network.
Step 2: Close the Java client that is automatically enabled by the upload operation (appears on Mac, not clear on other devices)
Pom is not displayed on the home page of jCenter project after the upload is successful
Question:
Pom is not displayed on the home page of jCenter project after uploading successfully. Click Add to JCenter and the following error message will pop up:
Please fix the following before submitting a JCenter inclusion request: - Add a POM file to the latest version of your package.
Copy the code
Javadoc generation fails due to coding problems.
Solution:
Step 1: Configure the following statement in the Project build.gradle:
. allprojects { ... Tasks. withType(Javadoc) {// New options.addStringOption('Xdoclint:none'.'-quiet')
options.addStringOption('encoding'.'UTF-8')}}...Copy the code
Step 2: Split upload command:
1. Run the gradlew clean build command in Terminal.
2, right click on the first execution generatePomFileForReleasePublication task, and then right-click the execution publishReleasePublicationToMavenLocal task, specific operation at the picture:
4. Run gradlew bintrayUpload -pbintrayuser =username -pbintraykey =API Key -pdryrun =false in Terminal