Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
603 views
in Technique[技术] by (71.8m points)

android - HTTP/1.1 401 Unauthorized when uploading binary on bintray

I'm trying to upload a android library module from android studio, followed by this blog: https://inthecheesefactory.com/blog/how-to-upload-library-to-jcenter-maven-central-as-dependency/en

(1)

./gradlew install

Result:- BUILD SUCCESSFUL

(2)

./gradlew build bintrayUpload

Result:- Getting below error-

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':acr:bintrayUpload'.

    Could not create version '1.0.0': HTTP/1.1 401 Unauthorized [message:This resource requires authentication]

I checked many times and sure my username and apikey is correct. (In username i'm using organization name instead of bintray username because my repository is created under organization). If anyone has an idea, I would appreciate the help :)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

In Bintray your username must be the username of your user account and not the Organisation. If you are the owner of the repo then the permission mechanism will allow the action.

In username i'm using organization name

Some documentation links:

https://github.com/bintray/gradle-bintray-plugin#readme

https://bintray.com/docs/usermanual/formats/formats_mavenrepositories.html#_working_with_gradle

EDIT: Make sure you are using the userOrg parameter, since your repo is under the organization subject and not under the user.

check step 4 here: https://github.com/bintray/gradle-bintray-plugin#step-4-add-your-bintray-package-information-to-the-bintray-closure

Here is a working build.gradle:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7'
    }
}


plugins {
    id "com.jfrog.bintray" version "1.7"
}


apply plugin: 'com.jfrog.bintray'
apply plugin: 'java'

bintray {
    user = 'myuserusername'
    key = '**********'
    pkg {
        repo = 'gradlerepo'
        name = 'gradlepackage'
        userOrg = 'myorgname'
        version {
            name = '1.0-Final'
        }
    }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...