4

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' 
R. Zagórski
  • 20,020
  • 5
  • 65
  • 90
harikrishnan
  • 1,985
  • 4
  • 32
  • 63

2 Answers2

3

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

R. Zagórski
  • 20,020
  • 5
  • 65
  • 90
  • thank you for your update. let me check and update Zagorski – harikrishnan Dec 06 '16 at 07:01
  • I have tried above one.but, now, am getting this error. Execution failed for task ':app:bintrayUpload'. > Could not create package 'vhkrishnanv16/maven/app': HTTP/1.1 404 Not Found [message:Repo 'maven' was not found] – harikrishnan Dec 06 '16 at 07:13
  • but,I have one organization with one repository with one product name. My OrgName: irah16, repo: maven , prod: app. the above four lines,dont know clearly,where to use it. – harikrishnan Dec 06 '16 at 07:17
  • if you want i will upload my full sample code here. otherwise, can u give any working bintrayupload sample program. i will use the same with replace my repo and app name in build.gradle files.past 2 weeks, i am struggling this place. vhkrishnan.v@gmail.com – harikrishnan Dec 06 '16 at 07:19
  • I've looked into your bintray account. First of all your Maven type repo is called `harimaven`. So one of the variables should be `bintrayRepo = 'harimaven'` Maybe you have changed it during tests. Then invoke commands `gradlew install` and `gradleW bintrayUpload`. I've already pushed 2 repos to jCenter: https://bintray.com/robertzagorski . You might look at the source code at github. – R. Zagórski Dec 06 '16 at 08:06
  • Tk your reply.I have two maven repo.maven,harimaven also.now, referring your code,am trying same for me. one doubt, before trying code to bintry upload procedure. is mandatory to upload my library code to Github first ? or no need. (here build.gradle, using siteurl,giturl ) – harikrishnan Dec 07 '16 at 07:11
  • I don't think this is needed. Probably you can leave those variables empty,l. – R. Zagórski Dec 07 '16 at 07:20
  • i left git url as empty now. i tried this. getting error (Could not get unknown property 'publishedGroupId' for project ':app' of type org.gradle.api.Project. ) when i saw your code seperate library is uploading. but, here am uploading app module itself. when i try to gradle sync. getting above error. – harikrishnan Dec 07 '16 at 07:34
  • Are you still using `install.gradle` and `bintray.gradle` from github links: https://raw.githubusercontent.com/nuuneoi... ? The second line in `install.gradle` is `group = publishedGroupId`. I imported those files into project because I had to import file with those variables into it. The second line in my project files is `apply from: '../bintray.data.gradle'`, because `install.gradle` and `bintray.gradle` must know about this file. – R. Zagórski Dec 07 '16 at 08:13
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/129980/discussion-between-harikrishnan-and-r-zagorski). – harikrishnan Dec 07 '16 at 08:24
  • getting error : Failed to resolve com.test.testsdkproj16:app122016:1.0.1 in new project – harikrishnan Dec 08 '16 at 07:21
  • Indeed, there is no package under https://jcenter.bintray.com/com/test/testsdkproj16/app122016/1.0.1 . But this is jCenter problem, why the package is not present under this address, you have to ask them. – R. Zagórski Dec 08 '16 at 08:22
  • thank you Zag.but, onething yar, when i click button include my package button and showing Include one of your packages in this repository edit box, my app122016 is already there. again what should i make include my package yar? my doubt, final step, if i anything missed steps (i requested mail to bintray also ) – harikrishnan Dec 08 '16 at 09:07
0

seems like you are missing the userOrg parameter. Please look at the following threads:

HTTP/1.1 401 Unauthorized when uploading binary on bintray

Trouble Publishing Android Studio Library on jCenter with Bintray

publish my android aar to jcenter

In short, your repo is under your org and not under your user account.

Community
  • 1
  • 1
galusben
  • 5,948
  • 6
  • 33
  • 52