You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Android Studio无法识别android-pdf-viewer库中PDFView组件的问题排查求助

Android Studio无法识别android-pdf-viewer库中PDFView组件的问题排查求助

我正在开发一个简单的Android应用来展示PDF文件,选用了barteksc的android-pdf-viewer库。我先在build.gradle里添加了依赖:

implementation 'com.github.barteksc:android-pdf-viewer:2.8.2'

接着在布局XML文件里引入PDFView组件:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".MainActivity">

    <com.github.barteksc.pdfviewer.PDFView
        android:id="@+id/idPDFView"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

</RelativeLayout>

但Android Studio给<com.github.barteksc.pdfviewer.PDFView>标了红色下划线,完全识别不了这个类。我后来换了一个版本的依赖:

implementation 'com.github.barteksc:android-pdf-viewer:3.2.0-beta.1'

问题还是没解决——不管是XML里还是Java/Kotlin代码里,PDFView类都不被识别。

我已经尝试过的方法:

  • 清理并重新构建项目
  • 多次同步Gradle
  • 清除缓存并重启Android Studio
  • 检查包名和拼写是否正确

期望的结果:

我希望Android Studio能正常识别PDFView组件,这样我就能在布局里使用它,并且在代码里正常引用它。

内容来源于stack exchange

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.08 09:18:10