androidandroid-studio-2.2android-maven-pluginbintrayjcenter

Android studio 2.2.2 publish my app module as library to jcenter with bintray repository


Here, I have done qr code scan project successfully. i have used for qrcodereaderview 1.0.0 v url repository library. this is my dependency.

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.dlazaro66.qrcodereaderview:qrcodereaderview:1.0.0'
    compile files('libs/ksoap2-android-assembly-3.2.0-jar-with-dependencies.jar')
}

I have only one app module in my project.I want to upload this project as a library(.AAR) to jcenter repository.

I have tried for some jcenter uploading steps and I got Successful upload response also from bintrayupload.

For this reason, I have created Github login and created project url. but, I did not upload my project code into github. I have given empty project url only in build.gradle.

but, when I saw in bintray repository.There is no code update/version change on my bintray maven repository.

Android Studio Project convert as .aar(library) file and uploading to jcenter repository in below steps following.

1). I have changed main app module build.gradle files for three changes.
Changed library plugin,commented application id and changed manifest file launcher activity.

My app module build.gradle file:

//apply plugin: 'com.android.application'
apply plugin: 'com.android.library'
ext {
    bintrayRepo = 'maven' //mavenrepo
    bintrayName = 'app'

    publishedGroupId = 'com.test.testsdkproj16'
    libraryName = 'TestsdkProj16'
    artifact = 'app'

    libraryDescription = 'A simple qr code library calling your project in Android'

    siteUrl = 'https://github.com/vhkrishnanv/TestsdkProj16'
    gitUrl = 'https://github.com/vhkrishnanv/TestsdkProj16.git'
    githubRepository= 'vhkrishnanv/TestsdkProj16'

    libraryVersion = '1.0.0'

    developerId = 'vhk*********6'
    developerName = 'harikrish'
    developerEmail = 'vhkris******@gmail.com'

    licenseName = 'The Apache Software License, Version 2.0'
    licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
    allLicenses = ["Apache-2.0"]
}
allprojects {
    repositories {
        jcenter()
    }
}
android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"
    defaultConfig {
        //applicationId "com.test.testsdkproj16"
        minSdkVersion 18
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.dlazaro66.qrcodereaderview:qrcodereaderview:1.0.0'
    compile files('libs/ksoap2-android-assembly-3.2.0-jar-with-dependencies.jar')
}

// Place it at the end of the file
apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle'
apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle'

My Manifest file:

 <activity android:name=".MainActivitySDK_16">
            <intent-filter>
                <action android:name="com.test.testsdkproj16.MainActivitySDK_16" />
                <!--comment when exporting AAR below two lines-->
                 <!--<action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.LAUNCHER" />-->
            </intent-filter>
        </activity>

gradle.properties file:

bintray.user=vhk*********6
bintray.apikey=***1f************************98f51***

2). Next Steps for upload my studio project to bintray.com. I have used three command for that.

-gradleW clean
BUILD SUCCESSFUL
-gradleW install
BUILD SUCCESSFUL
-gradleW bintrayupload
BUILD SUCCESSFUL

After executed the above three commands, when i saw in my bintray repository, there is no change in my repository.

My repository's screenshot

enter image description here

I dont know exactly what step is missing. Can anyone help to come out this error.

Overall I want to Publish my Studio2.2.2 project(converted as .aar library) to jcenter repository and need to get my project url this like. ( when i tried this url also in other new project in dependencies, getting error while sync,because, code/.aar not upload in repository)

I have one pending final steps is there. once code is uploaded, need to jcenter sync is pending in bintray repos.then only, I can able to use the above url to other New Project.

compile 'com.test.testsdkproj16:app:1.0.0' 

Solution

  • In your question you have written, that you keep credientials to bintray account in gradle.properties:

    bintray.user=vhk*********6
    bintray.apikey=***1f************************98f51***
    

    If you look into the source file from:

    https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle

    You will see the following lines:

    Properties properties = new Properties()
    properties.load(project.rootProject.file('local.properties').newDataInputStream())
    
    user = properties.getProperty("bintray.user")
    key = properties.getProperty("bintray.apikey")
    

    You have put the credientials in the wrong file. They should be in local.properties

    EDIT After long discussion finally the project was published to bintray. The problem here was that the user was publishing to another organisation project. So indeed, the answer made by @gba was correct. However, @harikrishnan was advised to download bintray.gradle and install.gradle to the project and modify them. Here is how they should look:

    bintray.gradle

    apply plugin: 'com.jfrog.bintray'
    apply from: '../bintray.data.gradle'
    
    version = libraryVersion
    
    if (project.hasProperty("android")) { // Android libraries
        task sourcesJar(type: Jar) {
            classifier = 'sources'
            from android.sourceSets.main.java.srcDirs
        }
    
        task javadoc(type: Javadoc) {
            options.addBooleanOption('Xdoclint:none', true)
            source = android.sourceSets.main.java.srcDirs
            classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
        }
    } else { // Java libraries
        task sourcesJar(type: Jar, dependsOn: classes) {
            classifier = 'sources'
            from sourceSets.main.allSource
        }
    }
    
    task javadocJar(type: Jar, dependsOn: javadoc) {
        classifier = 'javadoc'
        from javadoc.destinationDir
    }
    
    artifacts {
        archives javadocJar
        archives sourcesJar
    }
    
    Properties properties = new Properties()
    properties.load(new FileInputStream(file(rootProject.file('local.properties'))))
    
    bintray {
        user = properties.getProperty("bintray.user")
        key = properties.getProperty("bintray.apikey")
    
        configurations = ['archives']
        pkg {
            repo = bintrayRepo
            name = bintrayName
            desc = libraryDescription
            websiteUrl = siteUrl
            vcsUrl = gitUrl
            userOrg = userOrg
            licenses = allLicenses
            publish = true
            publicDownloadNumbers = true
        }
    }
    

    install.gradle

    apply plugin: 'com.github.dcendents.android-maven'
    apply from: '../bintray.data.gradle'
    
    group = publishedGroupId
    
    install {
        repositories.mavenInstaller {
            pom {
                project {
                    packaging 'aar'
                    groupId publishedGroupId
                    artifactId artifact
    
                    name libraryName
                    description libraryDescription
                    url siteUrl
    
                    licenses {
                        license {
                            name licenseName
                            url licenseUrl
                        }
                    }
                    developers {
                        developer {
                            id developerId
                            name developerName
                            email developerEmail
                        }
                    }
                    scm {
                        connection gitUrl
                        developerConnection gitUrl
                        url siteUrl
    
                    }
                }
            }
        }
    }
    

    bintray.data.gradle:

    ext {
        bintrayRepo = 'maven'
        bintrayName = 'samplename'
    
        publishedGroupId = 'sample.package.name'
        libraryName = 'SampleName'
        artifact = 'samplename'
    
        libraryDescription = ''
    
        siteUrl = ''
        gitUrl = ''
    
        libraryVersion = '1.0.0'
    
        developerId = ''
        developerName = 'Zagórski'
        developerEmail = ''
    
        licenseName = 'The Apache Software License, Version 2.0'
        licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
        allLicenses = ["Apache-2.0"]
    }
    

    app's build.gradle:

    apply plugin: 'com.android.application'
    
    (...)
    
    apply from: '../install.gradle'
    apply from: '../bintray.gradle'
    

    main build.gradle:

    buildscript {
        repositories {
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:2.2.2'
            classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.1'
            classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
            // NOTE: Do 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
    }
    

    A sample project that utilises those classes is here