在ProjectScopeServices中没有可用的Factory类型的服务


127
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'

// load properties
Properties properties = new Properties()
File localPropertiesFile = project.file("local.properties");
if(localPropertiesFile.exists()){
    properties.load(localPropertiesFile.newDataInputStream())
}
File projectPropertiesFile = project.file("project.properties");
if(projectPropertiesFile.exists()){
    properties.load(projectPropertiesFile.newDataInputStream())
}

//read properties
def projectName = properties.getProperty("project.name")
def projectGroupId = properties.getProperty("project.groupId")
def projectArtifactId = properties.getProperty("project.artifactId")
def projectVersionName = android.defaultConfig.versionName
def projectPackaging = properties.getProperty("project.packaging")
def projectSiteUrl = properties.getProperty("project.siteUrl")
def projectGitUrl = properties.getProperty("project.gitUrl")

def developerId = properties.getProperty("developer.id")
def developerName = properties.getProperty("developer.name")
def developerEmail = properties.getProperty("developer.email")

def bintrayUser = properties.getProperty("bintray.user")
def bintrayApikey = properties.getProperty("bintray.apikey")

def javadocName = properties.getProperty("javadoc.name")

group = projectGroupId

install {
    repositories.mavenInstaller {
        pom {
            project {
                name projectName
                groupId projectGroupId
                artifactId projectArtifactId
                version projectVersionName
                packaging projectPackaging
                url projectSiteUrl
                licenses {
                    license {
                        name 'The Apache Software License, Version 2.0'
                        url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
                    }
                }
                developers {
                    developer {
                        id developerId
                        name developerName
                        email developerEmail
                    }
                }
                scm {
                    connection projectGitUrl
                    developerConnection projectGitUrl
                    url projectSiteUrl
                }
            }
        }
    }
}

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
}

javadoc {
    failOnError false

    options{
        encoding 'UTF-8'
        charSet 'UTF-8'
        author true
        version projectVersionName
        links "http://docs.oracle.com/javase/7/docs/api"
        title javadocName
    }
}

bintray {
    user = bintrayUser
    key = bintrayApikey
    configurations = ['archives']
    pkg {
        repo = "maven"
        name = projectName
        websiteUrl = projectSiteUrl
        vcsUrl = projectGitUrl
        licenses = ["Apache-2.0"]
        publish = true
    }
}

使用此将代码上传到bintray将导致错误: No service of type Factory available in ProjectScopeServices. 如果我使用gradle 2.10可以正常运行,但是在2.14.1(AS 2.2预览版7需要2.14.1)下会出现此错误!


我遇到了同样的问题,在这里报告:code.google.com/p/android/issues/detail?id=219692(不幸的是,标题编辑得不好)
android开发者

Answers:


396

在项目build.gradle文件中将Maven Gradle插件版本更改为1.4.1

dependencies {
    classpath 'com.android.tools.build:gradle:2.2.2'
    classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
}

这个版本上传了吗?

伙计们,这个依赖项和类路径块是否需要放入build.gradle文件的buildscript部分中?
亚伦

12
有人可以解释如何解决此问题吗?
尼尔·加利亚斯卡罗夫

4
提供错误:找不到com.github.dcendents:android-maven-plugin:1.4.1。
阿披耶特(Abhijeet)

1
我吓坏了,不明白,但是这行得通,它也惹恼了我。
yUdoDis

7

只需将这行代码添加到您的项目级别gradle

dependencies{
   classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
}

0

我们不应该将任何静态版本用于Maven Gradle插件。从Android Studio根文件夹中的gradle-wrapper.properties文件检查您的distributionUrl 。根据提到的gradle版本,您可以从此链接中找到正确的 maven gradle插件版本

只需更新该版本即可解决您的问题。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.