Android Studio Release to Jcenter

Source: Internet
Author: User
Tags jfrog jcenter

1. Preface

Embrace open source, love open source, open the code we think is good to gihtub, publish our library to Jcenter\mevan and so on.

2. Preparation Work 2.1 Preparation
    • Apply for Warehouse Account
    • Make a signature file for it. JKs
2.2 Plugin Introduction

In the root directory, under the Gradle file, add

‘com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2‘        ‘com.github.dcendents:android-maven-plugin:1.2‘

Personally think that these 1 are best kept.
Finally, the Gradle file under our root directory becomes this way.

sub-projects/modules.buildscript {    repositories {        jcenter()    }    dependencies {        ‘com.android.tools.build:gradle:1.3.0‘        ‘com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2‘        ‘com.github.dcendents:android-maven-plugin:1.2‘        not place your application dependencies here; they belong        // in the individual module build.gradle files    }}allprojects {    repositories {        jcenter()    }}task clean(type: Delete) {    delete rootProject.buildDir}
2.3 Create a Bintray.gradle file under the root directory (this must be the name)
Group = Proj_groupversion = Proj_versionproject.archivesbasename = proj_artifactidapply Plugin:' Com.jfrog.bintray 'Apply plugin:' Maven-publish 'Task Sourcesjar (type: Jar) {from android.sourceSets.main.java.srcDirs classifier =' Sources '}task Javadoc (type: Javadoc) {Source = Android.sourceSets.main.java.srcDirs Classpath + = configurations.compile Classpath + = Proje Ct.files (Android.getbootclasspath (). Join (File.pathseparator))}task Javadocjar (type: Jar, Dependson:javadoc) {classifier =' Javadoc 'From Javadoc.destinationdir}javadoc {options{encoding"UTF-8"CharSet' UTF-8 'AuthortrueVersiontrueLinks"Http://docs.oracle.com/javase/7/docs/api"Title Proj_artifactid}}artifacts {Archives Javadocjar Archives Sourcesjar}defPomconfig = {licenses {license {name"The Apache software License, Version 2.0"wr."Http://www.apache.org/licenses/LICENSE-2.0.txt"Distribution"Repo"}} developers {developer {ID developer_id name developer_name email DEVEL Oper_email}}//There are quotation marks, and there is a space, otherwise can not generate dependency, mainly here is the dependencies is not build.gradle dependencies, and Gradle will treat him as his own dependencies    "Dependencies"{//dependency{//GroupId "Com.alibaba"//Artifactid "Fastjson"//"version" "1.2.6"//// with dependencies//        }}}publishing {publications {Mavenjava (mavenpublication) {Artifactid Proj_artifactid pom {Packaging' AAR '} pom.withxml {defroot = Asnode () Root.appendnode (' description ', proj_description) Root.children (). Last () + Pomconfig}}}}bintray {Properties p roperties =NewProperties () properties.load (Project.rootProject.file (' Local.properties '). Newdatainputstream ()) user = Properties.getproperty (' Bintray_user '); Key = Properties.getproperty (' Bintray_key '); configurations = [' Archives '] Publications = [' Mavenjava '] Publish =truepkg {repo =' maven 'name = Proj_name desc = proj_description Websiteurl = Proj_websiteurl Issuetrackerurl = Proj_issuetra Ckerurl Vcsurl = Proj_vcsurl licenses = [' Apache-2.0 '] Publicdownloadnumbers =true}}

The above files are rarely modified, if the package you are going to upload contains other three-party libraries. Make a statement in the following block

"dependencies " {//        dependency{//            groupId "com.alibaba"//            artifactId "fastjson"//            "version " "1.2.6"//            //同dependencies//        }    }

Easy to understand, at a glance, do not explain more.

2.4 Remaining configuration
    • In the model corresponding to the Gralde file configuration signature \ Introduce Bintray.gradle, the final code as follows, such as do not understand configuration related, read this or self-read gradle for Android
Apply plugin:' Com.android.application 'Android {Compilesdkversion atBuildtoolsversion"23.0.2"Signingconfigs {config {Keyalias' Guolei 'Keypassword' 123456 'StoreFilefile(' Guolei.jks ') Storepassword' 123456 '}} defaultconfig {ApplicationID"Com.gl.draggridview"Minsdkversion -Targetsdkversion atVersioncode1Versionname"1.0"} buildtypes {release {minifyenabledfalseProguardfiles Getdefaultproguardfile (' Proguard-android.txt '),' Proguard-rules.pro 'Signingconfig Signingconfigs.config}}}dependencies {compile Filetree (dir:' Libs ',include: [' *.jar '])//compile ' com.android.support:appcompat-v7:23.1.1 '}apply from:'. /bintray.gradle '

Note Bintray.gradle must be placed at the bottom of the file.

    • Configure Bintray_key and Bintray_user that's the one that started registering.

      guolei1130 for my username, view key Click Edit,

      Point API Key, show can see.
      The local.properties configuration under the root directory.
BINTRAY_KEY=e21c3f96df17xxxxxxxxBINTRAY_USER=guolei1130

This corresponds to this section of the code in Bintray.gradle, of course, you can modify this code, the 2 attributes are written in any position

PropertiesProperties()    properties.load(project.rootProject.file(‘local.properties‘).newDataInputStream())    user = properties.getProperty(‘BINTRAY_USER‘);    key = properties.getProperty(‘BINTRAY_KEY‘);

Finally, sync now.

3. Pre-upload 3.1 to generate the signed APK release package (will be checked when uploading)


Click on the corresponding model of the assemblerelease can, according to the subsequent error prompts, generate the corresponding package (this one should be able, I here is the release, debug package generated All)

3.2 Generating Jardocjar Sourcesjar

In the model corresponding to the other task, find the above 2, click Generate General non-Hui error

3.3 Click Task in publish to generate the Pom file


Click on the second one

3.4 Uploads

Click on the first task, if there is an error, according to troubleshooting, is generally the signature, verification of related issues.

4. Imported Jcenter (subject to review)


This Mevan warehouse is what I just uploaded, but we need to import him into Jcenter, click Jcenter. Click on the side import to filter the libraries that will be imported, and wait for the administrator to review them.

5. Finally, look at my library.

GitHub address, ask for a star
Finally, a picture proves that I just uploaded it.

Yes, that's so easy.

Android Studio Release to Jcenter

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.