繁体   English   中英

无法构建库项目Bintray Gradle - ClassNotFoundException

[英]Cannot build library project Bintray Gradle - ClassNotFoundException

我仍然试图让我的gradle脚本工作,我已经使用了所有日志,似乎有一些类缺失了。 这是消息。

org.gradle.api.GradleScriptException: A problem occurred evaluating project ':horizontalrecyclerview'.

Caused by: java.lang.NoClassDefFoundError: org/gradle/api/publication/maven/internal/DefaultMavenFactory
        at org.gradle.api.plugins.AndroidMavenPlugin.apply(AndroidMavenPlugin.java:88)
        at org.gradle.api.plugins.AndroidMavenPlugin.apply(AndroidMavenPlugin.java:57)
        at org.gradle.api.internal.plugins.ImperativeOnlyPluginApplicator.applyImperative(Imper

Caused by: java.lang.ClassNotFoundException: org.gradle.api.publication.maven.internal.DefaultMavenFactory
        ... 51 more

这是我的build.gradle

apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'
version = "1.0.0"
android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        minSdkVersion 8
        targetSdkVersion 21
        versionCode 1
        versionName "1.0.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
def siteUrl = 'https://github.com/CROSP/AndroidHorizontalRecyclerView'      // Homepage URL of the library
def gitUrl = 'https://github.com/CROSP/AndroidHorizontalRecyclerView.git'   // Git repository URL
group = "com.github.crosp.horizontalrecyclerview"                      // Maven Group ID for the artifact

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'org.jsoup:jsoup:1.8.1'
    compile 'com.android.support:appcompat-v7:22.1.1'
    compile 'com.android.support:recyclerview-v7:21.0.3'

}
install {
    repositories.mavenInstaller {
        // This generates POM.xml with proper parameters
        pom {
            project {
                packaging 'aar'

                // Add your description here
                name 'Android Horizontal Recycler View with Headerr'
                description = 'Android Horizontal Recycler View with Header project for displaying horizontal list on Android '
                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 'crosp'
                        name 'Alexandr Crospenko'
                        email 'crosp@xakep.ru'
                    }
                }
                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 = "crosp"
        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.
//            }
        }
    }
}

也许有人已经有这样的问题或知道解决它的方法? 请帮助,因为我不能整天工作。 Thx提前。

我正在做同样的事情(将我的aar上传到bintray)我也有同样的问题。

我知道它发生在gradle库中,所以我通过这种方式将我的gradle verion从2.4.0更改为2.2.1

文件 - >项目结构(或触发热键command + ; ) - >单击对话框左侧列表中的Project - > Gradle textedit框中的输入2.2.1。

我通过这种方式解决了这个错误。查看文件README.md中的注释部分。

希望这可以帮到你。

ps:如果你想使用gradle 2.4.0,你应该在项目根build.gradle的classpath中将android-maven-plugin版本配置为1.3,如下所示:

com.github.dcendents:android-maven-gradle-plugin:1.3

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM