为什么在调用setTargetInfo()之前无法调用getBootClasspath()?

内容来源于 Stack Overflow,并遵循CC BY-SA 3.0许可协议进行翻译与使用

  • 回答 (2)
  • 关注 (0)
  • 查看 (24)

C:\Users\Mansukh\Desktop\layout\MaterialDesignLibrary-master\MaterialDesign\build.gradle

Error:(97, 0) Cannot call getBootClasspath() before setTargetInfo() is called.

请告诉我这个错误的解决方案是什么。我试图找出互联网上的问题,但我无法得到特别的解决方案。

这是我的gradle.build文件。

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

android {
    compileSdkVersion 19
    buildToolsVersion '20.0.0'

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']

            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']

            renderscript.srcDirs = ['src']

            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }
        androidTest.setRoot('tests')
    }

    defaultConfig {
        minSdkVersion 8
        targetSdkVersion 21
        versionCode 6
        versionName '1.4'
    }
}

ext.siteUrl = 'https://github.com/navasmdc/MaterialDesignLibrary'
ext.issueUrl = 'https://github.com/navasmdc/MaterialDesignLibrary/issues'
ext.gitUrl = 'https://github.com/navasmdc/MaterialDesignLibrary.git'

bintray {
    user = hasProperty('BINTRAY_USER') ? BINTRAY_USER : "navasmdc"
    key = hasProperty('BINTRAY_KEY') ? BINTRAY_PASSWORD : ""

    configurations = ["archives"]
    pkg {
        repo = 'maven'
        name = 'MaterialDesignLibrary'
        desc = 'This is a library with components of Android L to you use in android 2.2'
        websiteUrl = siteUrl
        issueTrackerUrl = issueUrl
        vcsUrl = gitUrl
        licenses = ['Apache-2.0']
        labels = []
        publicDownloadNumbers = true
    }
}

dependencies {
    compile 'com.nineoldandroids:library:2.4.+'
    compile 'com.android.support:support-v4:21.+'
}

install {
    repositories.mavenInstaller {
        pom {
            project {
                packaging 'aar'
                name 'MaterialDesignLibrary'
                url siteUrl
                licenses {
                    license {
                        name 'The Apache Software License, Version 2.0'
                        url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
                    }
                }
                developers {
                    developer {
                        id 'navasmdc'
                        name 'Iván Navas'
                        email 'i.navas.mdc@gmail.com'
                    }
                }
                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
}

task findConventions << {
    println project.getConvention()
}
提问于
用户回答回答于

这是Gradle 1.1.0插件中的一个错误,如下所述:问题152811。Fix已经发布

解决方案是将插件版本更改为1.1.1或更高版本(当前可用版本为1.1.2)。 classpath 'com.android.tools.build:gradle:1.1.2'

用户回答回答于

我找到了一些解决办法,如果成功的话,试试这个

在Gradle文件中进行更改

task androidJavadocs(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
ext.androidJar = "${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar"
classpath += files(ext.androidJar)
}

上面的代码用这个替换

task javadoc(type: Javadoc) {
    source = android.sourceSets.main.java.srcDirs
    classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
} 

扫码关注云+社区