android - 发布android库到jcenter : gradle bintrayUpload does not find libraries

标签 android maven gradle android-gradle-plugin jcenter

我正在尝试将 Android 库发布到 jcenter。我关注了https://github.com/danielemaddaluno/gradle-jcenter-publish教程。在我尝试执行之前一切正常

gradle bintrayUpload

当我这样做时,我得到了构建失败。当我查看错误时,我看到了

包 com.android.volley 不存在

因此找不到我作为 gradle 依赖项包含的库

dependencies {
     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
    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.
//            }
        }
    }
}

和项目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()
    }
}

最佳答案

库在maven仓库中,所以需要声明maven中央仓库。将它添加到您的项目 build.gradle 文件中,如下所示:

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 - 发布android库到jcenter : gradle bintrayUpload does not find libraries,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29655103/

相关文章:

Android Studio应用显示问题

maven - NoClassDefFoundError : org. apache.commons.lang.StringUtils

maven - 无法在ubuntu 14.04上安装maven 3.3.3

java - 如何修复多模块 Maven 构建中的属性解析?

gradle - Gradle脚本中嵌套的动态属性?

gradle - 使用 Gradle 构建带有 Kotlin-DSL 依赖项的 jar

gradle - 依赖项冲突的Gradle Shadow Jar

java - ViewPager 中的 fragment 显示

android - 使用 faSTLane 重命名移动项目?

java - 调用对话框 : Not work on API 10