No service of type Factory available in ProjectScopeServices
Asked Answered
P

3

128
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
    }
}

use this to upload the code to bintray will lead the error: No service of type Factory available in ProjectScopeServices. if i use gradle 2.10 will run ok, but in the 2.14.1(AS 2.2 preview 7 need 2.14.1)will come this error!

Plotkin answered 8/8, 2016 at 9:21 Comment(1)
I have the same issue, reported here: code.google.com/p/android/issues/detail?id=219692 (sadly didn't edit title well)Jem
A
396

Change maven gradle plugin version to 1.4.1 in project build.gradle file

dependencies {
    classpath 'com.android.tools.build:gradle:2.2.2'
    classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
}
Ardin answered 10/8, 2016 at 10:59 Comment(5)
is this version uploaded?Plotkin
Guys does this dependencies and classpath chunk need to go inside a buildscript section of the build.gradle file?Worker
Can someone explain how this fixes issue?Reckless
Giving Error : Could not find com.github.dcendents:android-maven-plugin:1.4.1.Simferopol
I freaking dont understand, but this worked and it pissed me off as well.Ailment
H
7

Just add this line of code to your project level gradle

dependencies{
   classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
}
Heigl answered 24/3, 2018 at 10:1 Comment(0)
D
0

We should not use any static version for maven gradle plugin. Check your distributionUrl from gradle-wrapper.properties file inside Android studio root folder. Based on gradle version mentioned there you can find proper maven gradle plugin version from this link

just update that version that may solve your problem.

Dibranchiate answered 27/2, 2018 at 10:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.