gradle javadoc任务抛出的包androidx.appcompat.app不存在

guykilcj  于 2021-06-29  发布在  Java
关注(0)|答案(0)|浏览(235)

我想用gradle任务为我的android项目生成javadoc。在androidstudio中,我创建了一个带有空活动的新项目。如中所述https://stackoverflow.com/a/29396327 我补充说

task stackojavadoc(type: Javadoc) {
    source = android.sourceSets.main.java.srcDirs
    classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
    destinationDir = file("../javadoc/")
    //failOnError false
}

app/build.gradle . 但是现在

$ ./gradlew stackojavadoc
> Task :app:stackojavadoc FAILED
/home/.../GradleAndJavadoc/app/src/main/java/com/example/gradleandjavadoc/MainActivity.java:3: error: package androidx.appcompat.app does not exist
import androidx.appcompat.app.AppCompatActivity;
                             ^
/home/.../GradleAndJavadoc/app/src/main/java/com/example/gradleandjavadoc/MainActivity.java:7: error: cannot find symbol
public class MainActivity extends AppCompatActivity {
                                  ^
  symbol: class AppCompatActivity
2 errors

FAILURE: Build failed with an exception.

* What went wrong:

Execution failed for task ':app:stackojavadoc'.
> Javadoc generation failed. Generated Javadoc options file (useful for troubleshooting): '/home/.../GradleAndJavadoc/app/build/tmp/stackojavadoc/javadoc.options'

* Try:

Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s
1 actionable task: 1 executed

为什么这样不行?其他任务,如 assembleRelease (肯定会遇到同样的进口)工作得很好。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题