As you all know, Android Studio has a feature to use third-party jars directly in build.gradle

The compile 'com. Android. Support: design: 23.4.0'Copy the code

What does Android Studio do with this code? I don’t know, but I’m guessing it was downloaded from one of the servers. So let’s start today by uploading our own code to the sky and downloading it like this. First, create a new project (eclipse project, Android Studio Projec) :

First, apply for bintray.com and then do the following.

1. Add the following code to project build.gradle:

Classpath 'com. Jfrog. Bintray. Gradle: gradle bintray - plugin: 1.2' classpath 'com. Making. Dcendents: android - maven - gradle - plugin: 1.3'Copy the code

I don’t know you won’t because I won’t either haha:

2. Add the following code to build.gradle of module

apply plugin: 'com.android.application' apply plugin: 'com.github.dcendents.android-maven' apply plugin: 'com.jfrog.bintray' version = "1.0.0" Android {compileSdkVersion 24 buildToolsVersion "23.0.3" resourcePrefix "superbro" defaultConfig { applicationId "com.superbro.myapplication" minSdkVersion 15 targetSdkVersion 24 versionCode 1 VersionName "1.0"} buildTypes {release {minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: [' *. Jar ']) testCompile junit: junit: '4.12' compile 'com. Android. Support: appcompat - v7:24.0.0 - walk' compile 'com. Android. Support: design: 24.0.0 - walk' compile 'com. Android. Support: support - v4:24.0.0 - walk'} def siteUrl = 'https://github.com/choubaguai/PhotoSelecter' def gitUrl = 'https://github.com/choubaguai/PhotoSelecter' group = "com.superbro" install { repositories.mavenInstaller { pom { project { packaging 'aar' name 'Android Photo Selecter' url  siteUrl licenses { license { name 'The Apache Software License, Version 2.0 developers' url 'http://www.apache.org/licenses/LICENSE-2.0.txt'}} {developer {id 'superbro' name 'superbro' email '[email protected]' } } scm { connection gitUrl developerConnection gitUrl url siteUrl } } } } } task sourcesJar(type: Jar) { from android.sourceSets.main.java.srcDirs classifier = 'sources' } task javadoc(type: Javadoc) { source = android.sourceSets.main.java.srcDirs classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) } task javadocJar(type: Jar, dependsOn: javadoc) { classifier = 'javadoc' from javadoc.destinationDir } artifacts { archives javadocJar archives sourcesJar } Properties properties = new Properties() properties.load(project.rootProject.file('local.properties').newDataInputStream()) bintray { user = properties.getProperty("bintray.user") key = properties.getProperty("bintray.apikey") configurations = ['archives'] pkg {repo = "maven" name = "photoselecter" websiteUrl = siteUrl vcsUrl = gitUrl licenses = [" apache-2.0 "] publish = true} } javadoc { options{ encoding "UTF-8" charSet 'UTF-8' author true version true links "http://docs.oracle.com/javase/7/docs/api" } }Copy the code

3. Add: local.propertis



bintray.user=username
bintray.apikey=paikeyCopy the code

Some people will ask, how to get into this interface, well, look at the IP, YY. And then, when you go in and you click 1, it’s going to ask you to enter your password, and once you’ve entered your password, you click 2, you’ll see 3, and then you copy and paste.

Ok, at this point, you’ve done all the preparatory work, and then sync your project

By the time the synchronization is complete, the most important moment will be found in the lower row of Android Studio

Terminal, type it in

gradlew installCopy the code

If there are no problems, it will display:

BUILD SUCCESSFULCopy the code

Now we’re halfway there. The next step is to upload the compiled file to Bintray using the following command:

gradlew bintrayUploadCopy the code

If there are no problems, it will display:

BUILD SUCCESSFULCopy the code

Go to the website you just registered at this time you can see the project you uploaded, not finished, you open the project, there is a lower right corner

Click “Send” and then you can use it after the administrator approves it. How to use it? Well,

The following is the summary of the problem: 1, it indicates the gibberish code of GBK, which is usually in Chinese. There are Chinese annotations or other Chinese in the code you submit. The solution is to add the above code:

javadoc {
    options{
        encoding "UTF-8"
        charSet 'UTF-8'
        author true
        version true
        links "http://docs.oracle.com/javase/7/docs/api"
    }
}Copy the code

Use editPlus to change the encoding format of your file to UTF-8. Do not use Notepad.

3. The user name and APIKEY cannot be found because the case must be uniform.

HTTP/1.1 401 Unauthorized [message:This resource requires authentication]

The apikey and username values are incorrectly written.

Basically, these are the questions. The end.