【问题标题】:Not able to upload aar using gradle-bintray-plugin: only jar file is uploaded无法使用 gradle-bintray-plugin 上传 aar:仅上传 jar 文件
【发布时间】:2018-08-09 07:33:17
【问题描述】:

使用来自 here 的建议,我无法将我的 android aar 上传到我的 Bintray 帐户。我使用gradlew bintrayUpload 获得了“构建成功”,但在 bintray 中只能看到 jar 文件和 pom 文件。 这是我的顶级 gradle 文件

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'
    }
}
plugins {
    id "com.jfrog.bintray" version "1.7.3"
}
allprojects {
    repositories {
        jcenter()
    }
}
apply plugin: 'maven-publish'
apply plugin: 'java'
apply plugin: 'maven'

publishing {
    publications {
        MyPublication(MavenPublication) {
            from components.java
            groupId 'com.android.me.mylibrary'
            artifactId 'demo-lib'
            version '1.0.1'     
        }
    }
}

这是我的 gradle 文件

apply plugin: 'com.android.library'
bintray {
    user = user
    key = key
    publications = ['MyPublication'] //When uploading Maven-based publication files
    //configurations = ['archives']
    pkg {
        repo = repo
        name = 'demo-lib'
        userOrg = userorg
        labels = ['aar', 'android', 'example']
        version {
            name = '1.0.1'
        }
    }
}
android {
    compileSdkVersion 26
    buildToolsVersion "27.0.2"
    defaultConfig {
        minSdkVersion 21
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:26.+'
    testCompile 'junit:junit:4.12'
}

有什么遗漏吗? 我也尝试使用示例脚本here,但结果是一样的。 最好的问候...

【问题讨论】:

    标签: android gradle android-library bintray


    【解决方案1】:

    是的,实际上缺少一些东西。您不上传工件。您上传 artifactId 但不上传 artifact。

    因为有很多过时的教程,我实际上已经在here 发了一个关于这个的帖子。您还需要遵循 pom.xml 的 maven 规范,我发现您没有。

    在第 4 版中,它们也需要:

            pom.withXml {
                def root = asNode()
                root.appendNode('description', "libraryDescription")
                root.appendNode('name', "libraryName")
                root.appendNode('url', "siteUrl")
                root.children().last() + pomConfig
            }
    

    在 pomConfig 中你也应该像这样使用它:

    def pomConfig = {
        licenses {
            license {
                name "licenseName"
                url "licenseUrl"
                distribution "repo"
            }
        }
        developers {
            developer {
                id "developerId"
                name "developerName"
                email "developerEmail"
            }
        }
        scm {
            url "gitUrl"
        }
    }
    

    希望对你有帮助!!!

    【讨论】:

    • 嗨@matrix,我关注了你的文章并使用gradlew bintrayUpload我得到:Execution failed for task ':app:generatePomFileForMyPublicationPublication' Could not apply withXml() to generated POM Could not get unknown property 'api' for configuration container
    猜你喜欢
    • 2015-08-03
    • 2021-07-20
    • 2018-08-05
    • 1970-01-01
    • 2016-12-10
    • 1970-01-01
    • 2020-06-22
    • 1970-01-01
    • 2020-11-17
    相关资源
    最近更新 更多