Home

Awesome

Upload to JCenter/Bintray

This repository is no longer maintained

Jcenter has been sunset. It is encouraged to publish to MavenCentral.

Show some :heart:

GitHub stars GitHub forks GitHub watchers GitHub followers
Twitter Follow

Base repository to demonstrate the process of uploading an aar/jar to JCenter/Bintray.

Blog Post : Guide to publishing your Android Library via Jcenter/Bintray

The process is as follows

  1. Create an Android project or open an existing one in Android Studio

  2. Init the project with git and also create a repo on Github for the same. Each step here onwards represent a commit and should be pushed to github.

  3. Create and add a new module and choose Android Library.

    Goto File>New>New Module.. and select Android Library.

    newmodule

    newlib

    newlibinfo

  4. Implement your library code inside the library module you created in the last step.

  5. Next add the library module as a dependency to the app module.

    1. Goto File>Project Structure..
    2. Select app module in the sidebar
    3. Select the Dependencies tab
    4. At the bottom is a + icon, click that and select Module dependency and select your library module.
    5. Press apply or ok.

    project

    prjstruct

    addmodule

  6. Once project is synced, add the required plugins to classpath in build.gradle file at root project level, as shown below

    dependencies {
      classpath 'com.android.tools.build:gradle:4.1.1'
    
      ..
    
      // Required plugins added to classpath to facilitate pushing to Jcenter/Bintray
      classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
      classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
      ..
    
  7. Next, apply the bintray and install plugins at the bottom of build.gradle file at library module level. Also add the ext variable with required information as shown below

    apply plugin: 'com.android.library'
    
    ext {
     bintrayRepo = 'maven'
     bintrayName = 'awesomelib'   // Has to be same as your library module name
    
     publishedGroupId = 'com.github.nisrulz'
     libraryName = 'AwesomeLib'
     artifact = 'awesomelib'     // Has to be same as your library module name
    
     libraryDescription = 'Android Library to make any text into Toast with Awesome prepended to the text'
    
     // Your github repo link
     siteUrl = 'https://github.com/nisrulz/UploadToBintray'
     gitUrl = 'https://github.com/nisrulz/UploadToBintray.git'
     githubRepository= 'nisrulz/UploadToBintray'
    
     libraryVersion = '1.1'
    
     developerId = 'nisrulz'
     developerName = 'Nishant Srivastava'
     developerEmail = 'nisrulz@gmail.com'
    
     licenseName = 'The Apache Software License, Version 2.0'
     licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
     allLicenses = ["Apache-2.0"]
    }
    
    ..
    ..
    
    // Place it at the end of the file
    apply from: 'https://raw.githubusercontent.com/nisrulz/JCenter/master/installv1.gradle'
    apply from: 'https://raw.githubusercontent.com/nisrulz/JCenter/master/bintrayv1.gradle'
    
    
  8. Edit your local.properties

    bintray.user=<your_bintray_username>
    bintray.apikey=<your_bintray_apikey>
    
  9. Now lets setup Bintray before we can push our artifact to it.

    • Register for an account on bintray.com and click the activation email they send you.

    • Add a new Maven repository and click Create New Package

    • You should now have a maven repository. For instance: https://bintray.com/nisrulz/maven

    • Now once you have your maven repo setup , click on Edit

      edit

      and see that you have selected the option GPG sign uploaded files using Bintray's public/private key pair. and then click Update.

      gpg

  10. Once everything is configured, run the below in your terminal in your root of the project

    ./gradlew clean build install bintrayUpload
    
  11. Now once your project is up on bintray, simply hit Add to Jcenter button to sync with JCenter.

    addtojcenter

  12. Your code is available

    • through the private repo at bintray

      repositories { 
        google()
        jcenter()
        maven { url 'https://dl.bintray.com/<bintray_username>/maven' }
      }
      dependencies {
        compile 'com.github.<bintray_username>:<library_module>:1.1'
      }
      

      i.e for the sample lib in this repo , awesomelib

      repositories { 
        google()
        jcenter()
        maven { url 'https://dl.bintray.com/nisrulz/maven' }
      }
      dependencies {
        compile 'com.github.nisrulz:awesomelib:1.1'
      }
      
    • through JCenter if you have received the mail with confirmation

      finalmail

  13. Few things to note when you received the final email.

  1. You can use the lib now as follows

    dependencies {
        compile 'com.github.<bintray_username>:<library_module>:1.1'
      }
    

    i.e for the sample lib in this repo , awesomelib

    dependencies {
          compile 'com.github.nisrulz:awesomelib:1.1'
      }
    
  2. Let the world know of your AwesomeLib :smile:

    • Add a readme that explains how to integrate and use your Awesome library

    • Add a license block as in this repo

    • Also include the Bintray badge provided by Bintray in your readme

      badge

    • Promote your lib on social media so that others can know about it.

    • Always add a working sample app in your project that demonstrates your library in use.

    • Add screenshots if possible in your readme

If you appreciate my work, consider buying me a cup of :coffee: to keep me recharged :metal: [PayPal]

License

Copyright 2016 Nishant Srivastava

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.