gpt4 book ai didi

java - 由于包不存在,Android Studio 无法生成 Javadoc

转载 作者:行者123 更新时间:2023-12-04 23:58:34 31 4
gpt4 key购买 nike

当我尝试使用 Android Studio 工具为我的项目生成 Javadoc 时,出现了一系列错误,提示我正在使用的一堆包不存在。

C:\Users\Jadon\AndroidStudioProjects\QRHunterApp\app\src\main\java\com\example\qrhunter\loginQRCodeGeneratorActivity.java:8: error: package android.content does not exist
import android.content.Intent;
^
C:\Users\Jadon\AndroidStudioProjects\QRHunterApp\app\src\main\java\com\example\qrhunter\loginQRCodeGeneratorActivity.java:9: error: package android.graphics does not exist
import android.graphics.Bitmap;
^
C:\Users\Jadon\AndroidStudioProjects\QRHunterApp\app\src\main\java\com\example\qrhunter\loginQRCodeGeneratorActivity.java:10: error: package android.graphics does not exist
import android.graphics.Point;
^
C:\Users\Jadon\AndroidStudioProjects\QRHunterApp\app\src\main\java\com\example\qrhunter\loginQRCodeGeneratorActivity.java:11: error: package android.os does not exist
import android.os.Bundle;
^
C:\Users\Jadon\AndroidStudioProjects\QRHunterApp\app\src\main\java\com\example\qrhunter\loginQRCodeGeneratorActivity.java:12: error: package android.util does not exist
import android.util.Log;
^
C:\Users\Jadon\AndroidStudioProjects\QRHunterApp\app\src\main\java\com\example\qrhunter\loginQRCodeGeneratorActivity.java:13: error: package android.view does not exist
import android.view.Display;
^
C:\Users\Jadon\AndroidStudioProjects\QRHunterApp\app\src\main\java\com\example\qrhunter\loginQRCodeGeneratorActivity.java:14: error: package android.view does not exist
import android.view.View;
^
C:\Users\Jadon\AndroidStudioProjects\QRHunterApp\app\src\main\java\com\example\qrhunter\loginQRCodeGeneratorActivity.java:15: error: package android.view does not exist
import android.view.WindowManager;
^
C:\Users\Jadon\AndroidStudioProjects\QRHunterApp\app\src\main\java\com\example\qrhunter\loginQRCodeGeneratorActivity.java:16: error: package android.widget does not exist
import android.widget.ImageView;
^
C:\Users\Jadon\AndroidStudioProjects\QRHunterApp\app\src\main\java\com\example\qrhunter\loginQRCodeGeneratorActivity.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

我已经阅读了这个网站上我能找到的所有解决方案的答案,我发现的只是在生成 javadocs 工具的额外参数中使用 -bootclasspath 参数。

我尝试使用它,但它已被弃用,所以我切换到带有我的 android.jar 路径的 -sourcepath 参数,它似乎没有改变任何东西-sourcepath C:\Users\Jadon\AppData\Local\Android\Sdk\platforms\android-32\android.jar

如果有人知道解决此问题的方法,我将永远感激您。这让我很难受,因为我需要为我的成绩生成 javadoc。

最佳答案

我们遇到了同样的问题,终于找到了解决办法。将其放入您的 build.gradle(模块)并通过按 Strg+Strg 并键入 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"
}
}}

关于java - 由于包不存在,Android Studio 无法生成 Javadoc,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71721535/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com