Use of the Android studio maven Warehouse

Source: Internet
Author: User
Tags jfrog maven central jcenter

Transferred from: http://www.cnblogs.com/sihaixuan/p/4852974.html

Original: How to distribute your own Android library through Jcenter and Maven Central from Android Studio

Turn from: Translation http://www.jcodecraeer.com/a/anzhuokaifa/androidkaifa/2015/0623/3097.html

Blog: http://blog.csdn.net/jinyp/article/details/55095310

First, add a Jcenter library to maven.

If you want to introduce a library into your project in Android Studio, you simply add the following line of code to the module's Build.gradle file.

This makes it possible to use the library on the MAVEN repository.

1. We need to upload the local library to the Jcenter server before we can use Maven.

2, start uploading first we add two lines of code above the Build.gradle:

Buildscript {    repositories {        jcenter ()    }    dependencies {        classpath ' com.android.tools.build: gradle:2.3.0 '        //Note:do not place your application dependencies here, they belong        //In the individual module bu Ild.gradle files        //Add the following two lines of code.        classpath ' com.github.dcendents:android-maven-gradle-plugin:1.5 '        classpath ' com.jfrog.bintray.gradle: gradle-bintray-plugin:1.4 '    }}

3. Configure the Build.gradle inside the library

Apply plugin: ' com.android.library '//Add the following two lines of code here. Apply plugin: ' Com.github.dcendents.android-maven ' Apply plugin: ' Com.jfrog.bintray '//project reference version number, such as compile ' The 1.0.1 in com.yanzhenjie:andserver:1.0.1 ' is configured here. Version = "1.1.1"//defines two links, which are used below. def siteurl = ' https://gitee.com/lixiangyang8080/zxing_lxy_module '//Project home page. def giturl = URL of ' https://gitee.com/lixiangyang8080/zxing_lxy_module.git '//git repository. The only package name, such as the Com.yanzhenjie in compile ' com.yanzhenjie:andserver:1.0.1 ', is configured here.        Group = "Com.example.lenovo.zxing_lxy" Android {compilesdkversion-buildtoolsversion "26.0.1" Defaultconfig { Minsdkversion targetsdkversion Versioncode 1 Versionname "1.0" testinstrumentation Runner "Android.support.test.runner.AndroidJUnitRunner"} buildtypes {release {minifyenabled FAL Se proguardfiles getdefaultproguardfile (' proguard-android.txt '), ' Proguard-rules.pro '}}}dependencie s {compile filetree (include: [' *.jar '], diR: ' Libs ') androidtestcompile (' com.android.support.test.espresso:espresso-core:2.2.2 ', {Exclude group: ' Com.and Roid.support ', module: ' Support-annotations '}) Compile ' com.android.support:appcompat-v7:26.+ ' testcompile ' Juni t:junit:4.12 ' Compile files (' Libs/zxing-core-3.3.0.jar ')}install {repositories.maveninstaller {//Generate Pom.xml                and parameter Pom {project {packaging ' AAR '//Project description, copy my words, here needs to be modified.                Name ' zxing for Android '//optional, project names. Description ' The Android build the framework of the Http server. '                Optional, item description.                URL SiteURL//project home page, here is the reference above defined well.                Software Open source Agreement, now generally is Apache License2.0 bar, copy my, here do not need to modify.                        Licenses {license {name ' The Apache software license, Version 2.0 ' URL ' http://www.apache.org/licenses/LICENSE-2.0.txt '}}//Fill in Developer basic information, copy mine, hereNeed to be modified.                        Developers {developer {id ' 278918014 '//developer ID.                        Name ' Alley Yang '//developer names.                    email ' [[[email protected]] '//Developer email.                }}//SCM, copy My, there is no need to modify.                    SCM {Connection Giturl//git warehouse address.                    Developerconnection giturl//git warehouse address.                URL SiteURL//project home page. }}}}}//generates a task for the jar package and does not need to be modified. Task Sourcesjar (Type:jar) {from android.sourceSets.main.java.srcDirs classifier = ' sources '}//generate Jardoc task, no modification required 。 Task Javadoc (type:javadoc) {Source = Android.sourceSets.main.java.srcDirs Classpath + = Project.files (android.getbo Otclasspath (). Join (File.pathseparator))//Destinationdir = File (".. /javadoc/") FailOnError false//Ignore comment syntax error, compile if you write nonstandard on jdk1.8 your comment. }//generates Javadoc jar and does not need to be modified. Task Javadocjar (Type:jar, Dependson:javadoc) {Classifier = ' Javadoc ' from javadoc.destinationdir}artifacts {Archives Javadocjar Archives sourcesjar}//here is read Bintray related letters , we upload the project to GitHub when the Gradle file will be sent up, so do not put the account password information directly here, written in local.properties, here dynamic read. Properties Properties = new properties () Properties.load (Project.rootProject.file (' local.properties ').    Newdatainputstream ()) bintray {user = Properties.getproperty ("Bintray.user")//Bintray username.    Key = Properties.getproperty ("Bintray.apikey")//Bintray just saved Apikey. configurations = [' archives '] pkg {repo = "lxy-like"//upload to Maven library. (here to pay special attention, if you write maven 404 error, please create a warehouse in Bintray, here to fill in the name of the warehouse you created, how to create please see.)        Name = "Zxing-lxy"//Published to Bintray on the name of the project, where the name is not andserver in compile ' com.yanzhenjie:andserver:1.0.1 '.        userorg = Username of ' 278918014 '//Bintray, updated November 2016.    Websiteurl = SiteURL Vcsurl = giturl licenses = ["Apache-2.0"] publish = TRUE//Whether the project is public. }}

4. Configure Local.properties

5. Configure, upload.

6. Check your package on Bintray's website. You will find changes in the version area.

7. Click to go to the Files tab and you will see that we have uploaded the library file there.

Congratulations, your library has finally been put on the internet, anyone can use it!

But don't be too happy, the library is still in your own Maven repository, not on Jcenter. If someone wants to use your library, he must define the URL of the repository as follows:

8. Synchronize Bintray user warehouse to Jcenter

9. Do nothing directly by clicking Send.

All we can do now is wait for the Bintray team to review our request, about 2-3 hours. Once the sync request is approved, you will receive a message confirming the change. Now we go to the website to confirm that you will see some changes in the Linked to section.

10. Done.

Use of the Android studio maven Warehouse

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.