webdevqa.jp.net

設定後にバリアント「Android-lint」を作成できません

私のプロジェクトのGradleプラグインを2.1.2から3.1.0に更新していますが、gradleはビルド中にエラーをスローし始めます:

構成「:app:debugRuntimeElements」が解決された後、バリアント「Android-lint」を作成できません

プロジェクトレベルグラドル:

 // Top-level build file 
 buildscript {
repositories {
    jcenter()
    mavenCentral()
    maven { url 'https://maven.fabric.io/public' }
    maven {
        url 'https://maven.google.com/'
        name 'Google'
    }
    google()
}
dependencies {
    classpath 'com.Android.tools.build:gradle:3.1.1'
    classpath 'org.ajoberstar:gradle-git:0.6.3'
    //noinspection GradleDynamicVersion
    classpath 'io.fabric.tools:gradle:1.+'
    classpath 'me.tatarka:gradle-retrolambda:3.2.5'
    classpath 'com.google.gms:google-services:3.0.0'
}
}

 // Used to disable preDex, will speed up clean build but slow down incremental builds.
  project.ext.preDexLibs = !project.hasProperty('disablePreDex')

 subprojects {
project.plugins.whenPluginAdded { plugin ->
    if ("com.Android.build.gradle.AppPlugin".equals(plugin.class.name)) {
        project.Android.dexOptions.preDexLibraries = rootProject.ext.preDexLibs
    } else if ("com.Android.build.gradle.LibraryPlugin".equals(plugin.class.name)) {
        project.Android.dexOptions.preDexLibraries = rootProject.ext.preDexLibs
    }
}
}

allprojects {
repositories {
    jcenter()
 }
 }

ライブラリレベルグラドル:

 apply plugin: 'com.Android.library'

 setVersion '1.2'

repositories {
mavenCentral()
maven {
    url 'https://maven.google.com/'
    name 'Google'
}
}

configurations {
classpaths
}

def sharedManifest = manifest {
attributes('Specification-Title': 'My App',
           'Specification-Version': '2.1',
           'Specification-Vendor': 'App Vendor',
           'Implementation-Title': 'App',
           'Implementation-Version': '2.1',
           'Implementation-Vendor': 'App Vendor')
 }

Android {
compileSdkVersion 27
buildToolsVersion "27.0.3"

defaultConfig {
    minSdkVersion 15
    targetSdkVersion 27
    consumerProguardFile file("proguard-project.txt")
}

buildTypes {
    debug {
        testCoverageEnabled true
    }
}

// work-around for duplicate files during packaging of APK
packagingOptions {
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/NOTICE'
}

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {
implementation project(':exclude-doclet')
implementation 'com.Android.support:support-annotations:27.0.2'
implementation 'com.Android.support:support-v4:27.0.2'
implementation 'commons-io:commons-io:2.4'
implementation 'com.squareup.retrofit2:retrofit:2.1.0'
implementation 'com.squareup.retrofit2:converter-gson:2.1.0'
implementation 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
implementation 'com.google.code.gson:gson:2.4'
implementation 'io.reactivex:rxandroid:1.2.1'
implementation 'io.reactivex:rxjava:1.1.7'
classpaths files(new File(System.getenv("Android_HOME") + "/platforms/Android-${Integer.parseInt(rootProject.Android_BUILD_SDK_VERSION)}/Android.jar"),
        new File(System.getenv("Android_HOME") + "/extras/Android/support/v4/Android-support-v4.jar"))
testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:1.10.19'
androidTestImplementation 'junit:junit:4.12'
androidTestImplementation 'org.mockito:mockito-core:1.10.19'
}

Android.libraryVariants.all { variant ->
String name = variant.buildType.name
task("generate${name.capitalize()}Javadoc", type: Javadoc) {
    dependsOn variant.javaCompiler
    description "Generates Javadoc for $project.name."

    title "App $project.version"
    source = variant.javaCompiler.source
    classpath += project.files(variant.javaCompiler.classpath.files, Android.getBootClasspath())
    List<File> pathList = new ArrayList<File>()
    pathList.add(new File(project(':exclude-doclet').libsDir,
                          "ExcludeDoclet-${project(':exclude-doclet').version}.jar"))
    options {
        doclet = "ExcludeDoclet"
        docletpath = pathList
        encoding = "UTF-8"
        classpath = configurations.classpaths.files.asType(List)
        linksOffline "http://developer.Android.com/reference", "${Android.sdkDirectory}/docs/reference"
        links "http://docs.Oracle.com/javase/7/docs/api/",
              "http://square.github.io/retrofit/2.x/retrofit/",
              "http://square.github.io/okhttp/2.x/okhttp/",
              "http://reactivex.io/RxJava/javadoc/"
        memberLevel = JavadocMemberLevel.PUBLIC
        header = "AppKit"
    }
    exclude '**/BuildConfig.Java'
    exclude '**/R.Java'
    failOnError true

    doLast {
        copy {
            from 'src/javadoc/assets/'
            into destinationDir.path + '/assets/'
        }
    }
}

task("assemble${name.capitalize()}JavadocJar", type: Jar) {
    dependsOn "generate${name.capitalize()}Javadoc"
    description "Assembles Jar contaning Javadoc for $project.name."
    from project.tasks.getByName("generate${name.capitalize()}Javadoc").destinationDir
    classifier = 'javadoc'
    manifest {
        from sharedManifest
    }
}

task("assemble${name.capitalize()}Jar", type: Jar) {
    dependsOn variant.javaCompiler
    description "Assembles Jar contaning $project.name."
    from variant.javaCompiler.destinationDir
    manifest {
        from sharedManifest
    }
}

artifacts {
    archives project.tasks.getByName("assemble${name.capitalize()}Jar")
    archives project.tasks.getByName("assemble${name.capitalize()}JavadocJar")
}
}

私はこの問題にこだわっており、解決策が見つかりません。誰でも私を助けることができます。

12
Kapil Rajput

他のライブラリでも同じ問題が発生しました。この行を置き換えることで解決できました:

classpath = files(variant.javaCompile.classpath.files) + files(ext.androidJar)

で:

doFirst { classpath = files(variant.javaCompile.classpath.files) + files(ext.androidJar) },

「これは、JavaStudioプラグインと競合するAndroidStudioが更新されたときの新しいGradleプラグインが原因です。」Javadocタスクがある場合、同じ行を見つけることができる必要があります。

27
jatin kumar