gpt4 book ai didi

android - '从服务器 : Bad Request' While publishing aar file to Github packages 收到状态代码 400

转载 作者:行者123 更新时间:2023-11-30 04:57:35 26 4
gpt4 key购买 nike

我正在尝试将我的库推送到 GitHub Packages。我已经配置了个人访问 token ,并且在根文件夹中有 github.properties 文件。

使用gradle assemble组装aar文件。

当我运行 gradle publish 命令时。我收到此错误 Received status code 400 from server: Bad Request

* What went wrong:
Execution failed for task ':library_to_publish:publishProductionPublicationToGitHubPackagesRepository'.
> Failed to publish publication 'Production' to repository 'GitHubPackages'
> Could not write to resource 'https://maven.pkg.github.com/<user>/GitHubPackagesDemo/com/avp/test/lib/githubpackages/library_to_publish/1.0.6/library_to_publish-1.0.6.aar'.
> Could not PUT 'https://maven.pkg.github.com/<user>/GitHubPackagesDemo/com/avp/test/lib/githubpackages/library_to_publish/1.0.6/library_to_publish-1.0.6.aar'. Received status code 400 from server: Bad Request

这是我在build.gradle 文件中的配置

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'maven-publish'

def githubProperties = new Properties()
githubProperties.load(new FileInputStream(rootProject.file("github.properties")))

def getVersionName = { ->
return "1.0.6"
}

def getArtificatId = { ->
return "library_to_publish"
}

publishing {
publications {
Production(MavenPublication) {
groupId 'com.avp.test.lib.githubpackages' // Replace with group ID
artifactId getArtificatId()
version getVersionName()
artifact("$buildDir/outputs/aar/${getArtificatId()}-release.aar")

pom.withXml {
def dependenciesNode = asNode().appendNode('dependencies')

// Iterate over the implementation dependencies (we don't want the test ones),
// adding a <dependency> node for each
configurations.implementation.allDependencies.each {
// Ensure dependencies such as fileTree are not included in the pom.
if (it.name != 'unspecified') {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
dependencyNode.appendNode('artifactId', it.name)
dependencyNode.appendNode('version', it.version)
}
}
}
}

}

repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/<user>/GitHubPackagesDemo")
credentials {
username = githubProperties['gpr.usr'] ?: System.getenv("GPR_USER")
password = githubProperties['gpr.key'] ?: System.getenv("GPR_API_KEY")
}
}
}
}


有人知道为什么会这样吗?

最佳答案

我设法通过更改版本名称解决了这个问题。Github 不允许推送相同的版本来覆盖现有版本。每次发布都必须更新版本名称。

关于android - '从服务器 : Bad Request' While publishing aar file to Github packages 收到状态代码 400,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58857374/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com