StuStirling
StuStirling

Reputation: 16191

Gradle 3.0 Upgrade Causes androidJavadocs Error

I updated the following:

//gradle
classpath 'com.android.tools.build:gradle:3.0.0-beta6'
// library dependencies
implementation "com.android.support:appcompat-v7:26.1.0"
implementation "com.google.code.gson:gson:2.7"
implementation "com.google.android.gms:play-services-location:11.2.2"

I am now getting the following exception kinds of exceptions for the gradle task androidJavadocs.

error: package com.google.android.gms.security does not exist
error: package com.google.gson does not exist
error: cannot find symbol class NonNull

Here is the gradle task that used to allow me to package up the javadocs but this no longer suffices:

libraryVariants.all { variant ->
        if (variant.name == 'release') {
            task docs(type: Javadoc) {
                println 'docs task'
                source = variant.javaCompiler.source
                classpath += files(((Object) android.bootClasspath.join(File.pathSeparator)))
                classpath += files(variant.javaCompiler.classpath.files)
            }
        }
    }

I have tried lots of different combinations of gradle tasks and workarounds that I've found searching around but nothing works and I continue to get these errors. I have tried cleaning the project and invalidating the cache. Any ideas?

Upvotes: 1

Views: 483

Answers (1)

StuStirling
StuStirling

Reputation: 16191

Adding the following to my upload-archives.gradle file fixed the problem:

task androidJavadocs(type: Javadoc) {
        source = android.sourceSets.main.java.srcDirs
        // this is new
        android.libraryVariants.all { variant ->
            if (variant.name == 'release') {
                owner.classpath += variant.javaCompiler.classpath
            }
        }
        // end of new
        classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
    }

Upvotes: 2

Related Questions