0

我正在尝试按照本教程将库上传到 jCenter:

http://inthecheesefactory.com/blog/how-to-upload-library-to-jcenter-maven-central-as-dependency/en

当我执行 ./gradlew install 时,问题就来了。在生成 javadoc 时,我收到很多类似这样的错误:

/src/main/java/communicationManager/datareceiver/DeviceShimmer.java:7: error: package com.shimmerresearch.android does not exist
import com.shimmerresearch.android.Shimmer;

基本上,我的 Android Studio 模块中有一些需要使用的 jar 库,但在创建 javadoc 时找不到它们。我尝试将以下内容添加到我的模块 build.gradle,但没有运气:

task androidJavadocs(type: Javadoc) {
    source = android.sourceSets.main.java.srcDirs
    classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
    options.links("http://docs.oracle.com/javase/7/docs/api/");
    options.linksOffline "http://d.android.com/reference","${android.sdkDirectory}/docs/reference"
    exclude '**/BuildConfig.java'
    exclude '**/R.java'
    failOnError = false
}

task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
    classifier = 'javadoc'
    from androidJavadocs.destinationDir
}

task androidSourcesJar(type: Jar) {
    classifier = 'sources'
    from android.sourceSets.main.java.sourceFiles
}

artifacts {
    archives androidSourcesJar
    archives androidJavadocsJar
}

这就是我的项目 build.gradle 的样子:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "com.exampleapp"
        minSdkVersion 18
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'libs/commons-math-2.2.jar'
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.2.1'
    compile project(':mymodule')
}

这就是我的模块 build.gradle 的样子:

apply plugin: 'com.android.library'

ext {
    bintrayRepo = 'maven'
    bintrayName = 'name'

    publishedGroupId = 'com.name'
    libraryName = 'name'
    artifact = 'name'

    libraryDescription = 'description'

    siteUrl = 'https://github.com/...'
    gitUrl = 'https://github.com/...'

    libraryVersion = '2.0.1'

    developerId = '...'
    developerName = '...'
    developerEmail = '...'

    licenseName = 'GPL-3.0'
    licenseUrl = 'http://www.gnu.org/licenses/gpl-3.0.en.html'
    allLicenses = ["GPL-3.0"]
}

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        minSdkVersion 18
        targetSdkVersion 21
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }

    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'libs/commons-math-2.2.jar'
    }
}

dependencies {
    compile 'com.google.guava:guava:12.0'
    compile 'com.jjoe64:graphview:3.1.3'
    compile files('libs/ShimmerAndroidIntstrumentDriver_v2.6.jar')
    compile files('libs/ShimmerDriver_v2.6.jar')
    compile files('libs/wekaSTRIPPED.jar')
    compile files('libs/YouTubeAndroidPlayerApi.jar')
}

apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle'
apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle'


task androidJavadocs(type: Javadoc) {
    source = android.sourceSets.main.java.srcDirs
    classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
    options.links("http://docs.oracle.com/javase/7/docs/api/");
    options.linksOffline "http://d.android.com/reference","${android.sdkDirectory}/docs/reference"
    exclude '**/BuildConfig.java'
    exclude '**/R.java'
    failOnError = false
}

task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
    classifier = 'javadoc'
    from androidJavadocs.destinationDir
}

task androidSourcesJar(type: Jar) {
    classifier = 'sources'
    from android.sourceSets.main.java.sourceFiles
}

artifacts {
    archives androidSourcesJar
    archives androidJavadocsJar

任何帮助将非常感激!

4

1 回答 1

0

我遇到过同样的问题。我遇到的问题是我的机器上有两个或多个 java jdk 版本,或者在拥有最新 jre 的同时有一个过时的 java jdk。

删除所有 jdk 并拥有最新的 jdk 和 jre 解决了我的问题。

于 2015-09-28T06:06:11.073 回答