发布android库到jcenter:gradle bintrayUpload没有找到库 [英] Publish android library to jcenter: gradle bintrayUpload does not find libraries
问题描述
我正在尝试将Android库发布到jcenter。我遵循 https://github.com/danielemaddaluno/gradle-jcenter-publish 教程。一切正常,直到我尝试执行
gradle bintrayUpload
当我这样做时,我会遇到BUILD FAILED。当我查看错误时,我发现
$ b
package com.android.volley不存在
因此我没有找到作为gradle依赖项包含的库
依赖关系{
compile'com.mcxiaoke.volley:library:1. +'(...)
}
包含其他库的情况也一样。
如何解决这个问题?
附加模块build.gradle
apply plugin:'com.android.library'
apply plugin :'com.github.dcendents.android-maven'
apply plugin:com.jfrog.bintray
android {
compileSdkVersion 21
buildToolsVersion21.1。 2
defaultConfig {
minSdkVersion 8
targetSdkVersion 22
versionCode 1
versionName0.0.1
}
buildTypes {
版本{
minifyEnab导致false
proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.txt'
}
}
}
依赖关系{
compile'com.mcxiaoke.volley:library:1. +'
compile'com.shamanland:fab:0.0.8'
compile'com.google.code.gson:gson: 2.2.4'
compile'com.android.support:appcompat-v7:22.0.0'
compile'com.android.support:gridlayout-v7:21.0.3'
}
def siteUrl =SOME_URL
def gitUrl ='SOME_URL'
group =GROUP_ID
install {
repositories.mavenInstaller {
//这将生成具有合适参数的POM.xml
pom {
项目{
包装'aar'
//在这里添加描述
name' NAME'
description ='DESCRIPTION'
url siteUrl
//设置您的许可
许可证{
许可证{
名称'Apache软件许可证2.0版'
网址'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id'MY_ID'
name'MY_NAME'
email'MY_EMAIL'
}
}
scm {
connection gitUrl
developerConnection gitUrl
url siteUrl
}
}
}
}
}
任务sourcesJar(类型:Jar){
from android.sourceSets.main.java.srcDirs
classifier ='sources'
}
任务javadoc(类型:Javadoc){
source = android.sourceSets.main .java.srcDirs
classpath + = project.files(android.getBootClasspath()。join(File.pathSeparator))
}
任务javadocJar(类型:Jar,dependsOn: javadoc){
classifier ='javadoc'
from javadoc.destinationDir
}
artifacts {
archives javadocJar
archives sourcesJar
}
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties')。newDataInputStream())
// https: //github.com/bintray/gradle-bintray-plugin
bintray {
user = properties.getProperty(bintray.user)
key = properties.getProperty(bintray.apikey )
配置= ['档案']
pkg {
repo =maven
//它是在bintray中登录$ b $时出现的名称b name =androidupdatechecker
websiteUrl = siteUrl
vcsUrl = gitUrl
licenses = [Apache-2.0]
publish = true
版本{
gpg {
sign = true //确定是否对GPG签名文件。缺省值为false
passphrase = properties.getProperty(bintray.gpg.password)//可选。 GPG签名的密码短语'
}
// mavenCentralSync {
// sync = true //可选(默认为true)。确定是否将版本同步到Maven Central。
// user = properties.getProperty(bintray.oss.user)// OSS用户令牌
// password = properties.getProperty(bintray.oss.password)// OSS用户密码
// close ='1'//可选属性。默认情况下,分段存储库是关闭的,工件被发布到Maven Central。您可以选择关闭此行为(通过将值设为0)并手动发布版本。
//
}
}
}
和项目build.gradle
//顶级构建文件,您可以在其中添加对所有子项目都通用的配置选项/模块。
buildscript {
repositories {
jcenter()
}
依赖关系{
classpath'com.android.tools.build:gradle:1.1.2'
classpath'com.github.dcendents:android-maven-plugin:1.2'
classpathcom.jfrog.bintray.gradle:gradle-bintray-plugin:1.1
}
}
allprojects {
repositories {
jcenter()
}
}
库位于maven仓库中,因此您需要声明maven中央仓库。将它添加到你的项目中: build.gradle
这样的文件:
buildscript {
repositories {
mavenCentral()
jcenter()
}
依赖项{
classpath'com.android.tools.build:gradle:1.1。 2'
classpath'com.github.dcendents:android-maven-plugin:1.2'
classpathcom.jfrog.bintray.gradle:gradle-bintray-plugin:1.1
I'm trying to publish an Android library to jcenter. I've followed https://github.com/danielemaddaluno/gradle-jcenter-publish tutorial. Everything works fine until I try to execute
gradle bintrayUpload
When I do so I get a BUILD FAILED. When I look into the errors I see
package com.android.volley does not exist
Therefore the libraries that I have included as a gradle dependency are not being found
dependencies {
compile 'com.mcxiaoke.volley:library:1.+' (...)
}
The same happends with other libraries included.
How can I fix this problem?
I Attach the module build.gradle
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: "com.jfrog.bintray"
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 8
targetSdkVersion 22
versionCode 1
versionName "0.0.1"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.mcxiaoke.volley:library:1.+'
compile 'com.shamanland:fab:0.0.8'
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.android.support:gridlayout-v7:21.0.3'
}
def siteUrl = "SOME_URL"
def gitUrl = 'SOME_URL'
group = "GROUP_ID"
install {
repositories.mavenInstaller {
// This generates POM.xml with proper parameters
pom {
project {
packaging 'aar'
// Add your description here
name 'NAME'
description = 'DESCRIPTION'
url siteUrl
// Set your license
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id 'MY_ID'
name 'MY_NAME'
email 'MY_EMAIL'
}
}
scm {
connection gitUrl
developerConnection gitUrl
url siteUrl
}
}
}
}
}
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}
task javadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives javadocJar
archives sourcesJar
}
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
// https://github.com/bintray/gradle-bintray-plugin
bintray {
user = properties.getProperty("bintray.user")
key = properties.getProperty("bintray.apikey")
configurations = ['archives']
pkg {
repo = "maven"
// it is the name that appears in bintray when logged
name = "androidupdatechecker"
websiteUrl = siteUrl
vcsUrl = gitUrl
licenses = ["Apache-2.0"]
publish = true
version {
gpg {
sign = true //Determines whether to GPG sign the files. The default is false
passphrase = properties.getProperty("bintray.gpg.password") //Optional. The passphrase for GPG signing'
}
// mavenCentralSync {
// sync = true //Optional (true by default). Determines whether to sync the version to Maven Central.
// user = properties.getProperty("bintray.oss.user") //OSS user token
// password = properties.getProperty("bintray.oss.password") //OSS user password
// close = '1' //Optional property. By default the staging repository is closed and artifacts are released to Maven Central. You can optionally turn this behaviour off (by puting 0 as value) and release the version manually.
// }
}
}
}
and the project build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.2'
classpath 'com.github.dcendents:android-maven-plugin:1.2'
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.1"
}
}
allprojects {
repositories {
jcenter()
}
}
The library is in maven repository, so you need to declare the maven central repository. Add it in your project build.gradle
file like this:
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.2'
classpath 'com.github.dcendents:android-maven-plugin:1.2'
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.1"
}
}
这篇关于发布android库到jcenter:gradle bintrayUpload没有找到库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!