HTTP/1.1 401 Unauthorized when uploading binary on bintray

前端 未结 2 1782
孤城傲影
孤城傲影 2020-12-20 14:15

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

相关标签:
2条回答
  • 2020-12-20 14:46

    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'
            }
        }
    }
    
    0 讨论(0)
  • 2020-12-20 14:57

    I would like to add more to @gba's answer here

    Instead of directly including your bintray username and apikey, you should include them in local.properties file at root of your project. The local.properties file is by default added to .gitignore and hence not uploaded to githup with other files. It helps in keeping your username and apikey safe.

    bintray.user=<your bintray username>
    bintray.apikey=<your bintray apikey>
    

    Then in your module gradle file add:

    Properties properties = new Properties()
    properties.load(project.rootProject.file('local.properties').newDataInputStream())
    
    bintray {
        user = properties.getProperty("bintray.user")
        key = properties.getProperty("bintray.apikey")
    
        configurations = ['archives']
        pkg {
            repo = "maven"
            name = "<Your library name>"
            websiteUrl = <your siteUrl>
            vcsUrl = gitUrl
            licenses = ["Apache-2.0"]
            publish = true
        }
    }
    

    Reference: https://www.virag.si/2015/01/publishing-gradle-android-library-to-jcenter/

    0 讨论(0)
提交回复
热议问题