skip to Main Content

When I try to generate Javadocs for my projects using the Android Studio tool I get a series of errors that say a bunch of packages I am using do not exist.

C:UsersJadonAndroidStudioProjectsQRHunterAppappsrcmainjavacomexampleqrhunterloginQRCodeGeneratorActivity.java:8: error: package android.content does not exist
import android.content.Intent;
                      ^
C:UsersJadonAndroidStudioProjectsQRHunterAppappsrcmainjavacomexampleqrhunterloginQRCodeGeneratorActivity.java:9: error: package android.graphics does not exist
import android.graphics.Bitmap;
                       ^
C:UsersJadonAndroidStudioProjectsQRHunterAppappsrcmainjavacomexampleqrhunterloginQRCodeGeneratorActivity.java:10: error: package android.graphics does not exist
import android.graphics.Point;
                       ^
C:UsersJadonAndroidStudioProjectsQRHunterAppappsrcmainjavacomexampleqrhunterloginQRCodeGeneratorActivity.java:11: error: package android.os does not exist
import android.os.Bundle;
                 ^
C:UsersJadonAndroidStudioProjectsQRHunterAppappsrcmainjavacomexampleqrhunterloginQRCodeGeneratorActivity.java:12: error: package android.util does not exist
import android.util.Log;
                   ^
C:UsersJadonAndroidStudioProjectsQRHunterAppappsrcmainjavacomexampleqrhunterloginQRCodeGeneratorActivity.java:13: error: package android.view does not exist
import android.view.Display;
                   ^
C:UsersJadonAndroidStudioProjectsQRHunterAppappsrcmainjavacomexampleqrhunterloginQRCodeGeneratorActivity.java:14: error: package android.view does not exist
import android.view.View;
                   ^
C:UsersJadonAndroidStudioProjectsQRHunterAppappsrcmainjavacomexampleqrhunterloginQRCodeGeneratorActivity.java:15: error: package android.view does not exist
import android.view.WindowManager;
                   ^
C:UsersJadonAndroidStudioProjectsQRHunterAppappsrcmainjavacomexampleqrhunterloginQRCodeGeneratorActivity.java:16: error: package android.widget does not exist
import android.widget.ImageView;
                     ^
C:UsersJadonAndroidStudioProjectsQRHunterAppappsrcmainjavacomexampleqrhunterloginQRCodeGeneratorActivity.java:26: error: cannot access ViewGroup
public class loginQRCodeGeneratorActivity extends AppCompatActivity {
       ^
  class file for android.view.ViewGroup not found
javadoc: error - fatal error encountered: java.lang.NullPointerException
javadoc: error - Please file a bug against the javadoc tool via the Java bug reporting page
(http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com)
for duplicates. Include error messages and the following diagnostic in your report. Thank you.
java.lang.NullPointerException
    at jdk.compiler/com.sun.tools.javac.comp.TypeEnter$MembersPhase.runPhase(TypeEnter.java:934)
    at jdk.compiler/com.sun.tools.javac.comp.TypeEnter$Phase.doCompleteEnvs(TypeEnter.java:282)
    at jdk.compiler/com.sun.tools.javac.comp.TypeEnter$MembersPhase.doCompleteEnvs(TypeEnter.java:877)
    at jdk.compiler/com.sun.tools.javac.comp.TypeEnter$Phase.completeEnvs(TypeEnter.java:251)
    at jdk.compiler/com.sun.tools.javac.comp.TypeEnter$Phase.completeEnvs(TypeEnter.java:266)
    at jdk.compiler/com.sun.tools.javac.comp.TypeEnter$Phase.completeEnvs(TypeEnter.java:266)
    at jdk.compiler/com.sun.tools.javac.comp.TypeEnter$Phase.completeEnvs(TypeEnter.java:266)
    at jdk.compiler/com.sun.tools.javac.comp.TypeEnter.complete(TypeEnter.java:198)
    at jdk.compiler/com.sun.tools.javac.code.Symbol.complete(Symbol.java:642)
    at jdk.compiler/com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:1326)
    at jdk.compiler/com.sun.tools.javac.comp.Enter.complete(Enter.java:583)
    at jdk.compiler/com.sun.tools.javac.comp.Enter.main(Enter.java:560)
    at jdk.javadoc/jdk.javadoc.internal.tool.JavadocEnter.main(JavadocEnter.java:79)
    at jdk.javadoc/jdk.javadoc.internal.tool.JavadocTool.getEnvironment(JavadocTool.java:206)
    at jdk.javadoc/jdk.javadoc.internal.tool.Start.parseAndExecute(Start.java:576)
    at jdk.javadoc/jdk.javadoc.internal.tool.Start.begin(Start.java:432)
    at jdk.javadoc/jdk.javadoc.internal.tool.Start.begin(Start.java:345)
    at jdk.javadoc/jdk.javadoc.internal.tool.Main.execute(Main.java:63)
    at jdk.javadoc/jdk.javadoc.internal.tool.Main.main(Main.java:52)
12 errors

"javadoc" finished with exit code 4

I have read every answer on this website I can find for a solution to this, and all I have found is to use the -bootclasspath argument in the extra arguments for the generate javadocs tool.

I tried to use that but it is deprecated, so I switched to the -sourcepath argument with the path to my android.jar, it doesn’t seem to change anything
-sourcepath C:UsersJadonAppDataLocalAndroidSdkplatformsandroid-32android.jar

If anyone knows some way to fix this I would be forever in your debt. This is killing me as I need to have the javadocs generated for my grade.

3

Answers


  1. We had the same problem and finally found a solution. Put this in your build.gradle (Module) and execute it by pressing Strg+Strg and type gradle generateReleaseJavadoc

    android.applicationVariants.all { variant ->
        task("generate${variant.name.capitalize()}Javadoc", type: Javadoc) {
            description "Generates Javadoc for $variant.name."
    
            source = variant.javaCompile.source
            destinationDir = file("$rootDir/javadoc/")
            failOnError false
    
            doFirst {
                ext.androidJar = "${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar"
                classpath = files(variant.javaCompile.classpath.files) + files(ext.androidJar)
    
                options.addStringOption "-show-members", "package"
            }
        }}
    
    Login or Signup to reply.
  2. I experienced the same problem and as a workaround, I generated the JavaDocs using Intellij. It’s free for students, if that helps.

    Login or Signup to reply.
  3. I have 2 solutions for this problem:

    1. Implementing android.jar in the module that needs it:
      Go to Project View > External Libraries > unfold Android API X Plataform > click right in android.jar > Copy Path > Absolute Path > go to gradle and paste the path in implementation files:
    dependencies{
    implementation files('Paste Here')
    }
    

    Then try again go to Tools > Generate Javadoc and generate it.

    Don’t forget to remove the (implementation files…) line once you’ve managed to generate your javadoc.

    1. Use gradle as indicated by this solution that I published recently: Here
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search