Search code examples
androidgradlebintrayjcenter

Uploading android module to bintray and linking to jcenter


Hi so I'm following the github site of Gradle Bintray Plugin https://github.com/bintray/gradle-bintray-plugin#readme tutorial however I don't quite understand the publications part. Can anyone help me with this? I'am currently working on bintray version 1.7.3.

Update: I was able to upload successfully in bintray. However my current problem now is when downloading it in other projects. I have errors when syncing gradle :
-Could not find android-dbpatcher.jar(sirqo:android-dbpatcher:0.0.1).
-Error: Searched in the following locations:
http://sirqo.bintray.com/Android-DBPatcher/sirqo/android-dbpatcher/0.0.1/android-dbpatcher-0.0.1.jar

Update2: For reference this is my gradle.build in my module

apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.1"

    defaultConfig {
        minSdkVersion 9
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner     "android.support.test.runner.AndroidJUnitRunner"

    }
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-  core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
    compile 'com.android.support:appcompat-v7:25.0.1'
    testCompile 'junit:junit:4.12'
    compile 'com.android.volley:volley:1.0.0'
}

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
}

group = 'xxxx'
version = '0.0.1'

install {
    repositories.mavenInstaller {
        pom.project {
            name 'android-dbpatcher'
            description 'A library for updating SQLite database in android.'
            url 'https://sirqo.bintray.com/Android-DBPatcher'
            inceptionYear '2016'

            packaging 'aar'
            groupId 'xxxx'
            artifactId 'android-dbpatcher'
            version '0.0.1'

            licenses {
                license {
                    name "The Apache Software License, Version 2.0"
                    url "http://www.apache.org/licenses/LICENSE-2.0.txt"
                    distribution "repo"
                }
            }

            developers {
                developer {
                    id  'xxxx'
                    name 'xxxxx'
                    email '[email protected]'
                }
            }
        }
    }
}

Properties bintrayProperties = new Properties()
    bintrayProperties.load(project.rootProject.file('bintray.properties').newDa    taInputStream())

bintray {
    user = bintrayProperties.getProperty('user')
    key = bintrayProperties.get('key')
    configurations = ['archives']
    pkg {
        repo = 'Android-DBPatcher'
        name = 'android-dbpatcher'
        userOrg = 'xxxx'
        vcsUrl = 'https://github.com/sirqo/android-dbpatcher'
        publish = true
        version {
            name = '0.0.1'
            desc = 'Android SQLite Database Patcher'
            released = new Date()
            vcsTag = 'v0.0.1'
        }
    }
}

Solution

  • So I figured it out. For reference I'll share my code.

    For my Project gradle.build

    // 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:2.2.2'
            classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
            classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7'
            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        }
    }
    
    plugins {
        id "com.jfrog.bintray" version "1.7.3"
    }
    
    allprojects {
        repositories {
            jcenter()
        }
    
    }
    
    task clean(type: Delete) {
        delete rootProject.buildDir
    }
    

    And for my module gradle.build

    apply plugin: 'com.android.library'
    apply plugin: 'com.github.dcendents.android-maven'
    apply plugin: 'com.jfrog.bintray'
    
    android {
        compileSdkVersion 25
        buildToolsVersion "25.0.1"
    
        defaultConfig {
            minSdkVersion 9
            targetSdkVersion 25
            versionCode 1
            versionName "1.0"
    
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    }
    
    dependencies {
            compile fileTree(dir: 'libs', include: ['*.jar'])
            androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
                exclude group: 'com.android.support', module: 'support-annotations'
        })
        compile 'com.android.support:appcompat-v7:25.0.1'
        testCompile 'junit:junit:4.12'
        compile 'com.android.volley:volley:1.0.0'
    }
    
    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
    }
    
    group = 'xxxx' //bintray org/group name
    version = '0.0.1' //version
    
    install {
        repositories.mavenInstaller {
            pom.project {
                name 'xxxxx' //package name
                description 'A library for updating SQLite database in android.'
                url 'xxxxx'
                inceptionYear '2016'
    
                packaging 'aar'
                groupId 'xxxx' //group/org id
                artifactId 'xxxx' //your android module name
                version '0.0.1'
    
                licenses {
                    license {
                        name "The Apache Software License, Version 2.0"
                        url "http://www.apache.org/licenses/LICENSE-2.0.txt"
                        distribution "repo"
                    }
                }
    
                developers {
                    developer {
                        id  'xxxxx' //developer username
                        name 'xxxxxx' //developer name
                        email '[email protected]' //developer email
                    }
                }
                scm {
                    connection 'xxxxxx' // YOUR GIT REPO
                    developerConnection 'xxxxxx' // YOUR GIT REPO
                    url 'xxxxxxx' // YOUR SITE
    
                }
            }
        }
    }
    
    Properties bintrayProperties = new Properties()
    bintrayProperties.load(project.rootProject.file('bintray.properties').newDataInputStream())
    
    bintray {
        user = bintrayProperties.getProperty('user')
        key = bintrayProperties.get('key')
        configurations = ['archives']
        pkg {
            repo = 'xxxxxx' //Bintray repository
            name = 'xxxxxx' //Bintray Package name
            userOrg = 'xxxxx'
            licenses = ['Apache-2.0']
            vcsUrl = 'xxxxxxxx'
            publish = true
            version {
                name = '0.0.1' //version
                desc = 'xxxxxx' //Description
                released = new Date()
                vcsTag = 'v0.0.1'
            }
        }
    }
    

    After this open the android terminal below in your android studio and enter this command

    ./gradlew install

    • if there is some errors you can append the command with --debug and re-enter the command to trace the error

    //if nothing else fail issue this command ./gradlew bintrayUpload *again if there is an error you can use the command and append with --debug to trace it.

    after all these you will recieve an email or something and then you can proceed to downloading your library in other projects. Happy coding!