news 2026/7/13 19:17:52

Android 引入 AndroidPdfViewer 问题:Duplicate class android.support.v4.app.AppLaunchChecker...

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
Android 引入 AndroidPdfViewer 问题:Duplicate class android.support.v4.app.AppLaunchChecker...
implementation'com.github.barteksc:android-pdf-viewer:3.2.0-beta.1'
  • 在 Android 开发中,引入 AndroidPdfViewer 后,构建项目时,出现如下错误信息
Execution failed for task ':view:checkDebugDuplicateClasses'. > A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable > Duplicate class android.support.v4.app.AppLaunchChecker found in modules support-compat-28.0.0-runtime (com.android.support:support-compat:28.0.0) and support-core-utils-26.1.0-runtime (com.android.support:support-core-utils:26.1.0) Duplicate class android.support.v4.app.FrameMetricsAggregator found in modules support-compat-28.0.0-runtime (com.android.support:support-compat:28.0.0) and support-core-utils-26.1.0-runtime (com.android.support:support-core-utils:26.1.0) Duplicate class android.support.v4.app.FrameMetricsAggregator$FrameMetricsApi24Impl found in modules support-compat-28.0.0-runtime (com.android.support:support-compat:28.0.0) and support-core-utils-26.1.0-runtime (com.android.support:support-core-utils:26.1.0) Duplicate class android.support.v4.app.FrameMetricsAggregator$FrameMetricsApi24Impl$1 found in modules support-compat-28.0.0-runtime (com.android.support:support-compat:28.0.0) and support-core-utils-26.1.0-runtime (com.android.support:support-core-utils:26.1.0) Duplicate class android.support.v4.app.FrameMetricsAggregator$FrameMetricsBaseImpl found in modules support-compat-28.0.0-runtime (com.android.support:support-compat:28.0.0) and support-core-utils-26.1.0-runtime (com.android.support:support-core-utils:26.1.0) Duplicate class android.support.v4.app.FrameMetricsAggregator$MetricType found in modules support-compat-28.0.0-runtime (com.android.support:support-compat:28.0.0) and support-core-utils-26.1.0-runtime (com.android.support:support-core-utils:26.1.0) Duplicate class android.support.v4.app.INotificationSideChannel found in modules core-1.9.0-runtime (androidx.core:core:1.9.0) and support-compat-28.0.0-runtime (com.android.support:support-compat:28.0.0) Duplicate class android.support.v4.app.INotificationSideChannel$Stub found in modules core-1.9.0-runtime (androidx.core:core:1.9.0) and support-compat-28.0.0-runtime (com.android.support:support-compat:28.0.0) Duplicate class android.support.v4.app.INotificationSideChannel$Stub$Proxy found in modules core-1.9.0-runtime (androidx.core:core:1.9.0) and support-compat-28.0.0-runtime (com.android.support:support-compat:28.0.0) Duplicate class android.support.v4.app.NavUtils found in modules support-compat-28.0.0-runtime (com.android.support:support-compat:28.0.0) and support-core-utils-26.1.0-runtime (com.android.support:support-core-utils:26.1.0) Duplicate class android.support.v4.app.TaskStackBuilder found in modules support-compat-28.0.0-runtime (com.android.support:support-compat:28.0.0) and support-core-utils-26.1.0-runtime (com.android.support:support-core-utils:26.1.0) Duplicate class android.support.v4.app.TaskStackBuilder$SupportParentable found in modules support-compat-28.0.0-runtime (com.android.support:support-compat:28.0.0) and support-core-utils-26.1.0-runtime (com.android.support:support-core-utils:26.1.0) Duplicate class android.support.v4.content.FileProvider found in modules support-compat-28.0.0-runtime (com.android.support:support-compat:28.0.0) and support-core-utils-26.1.0-runtime (com.android.support:support-core-utils:26.1.0) Duplicate class android.support.v4.content.FileProvider$PathStrategy found in modules support-compat-28.0.0-runtime (com.android.support:support-compat:28.0.0) and support-core-utils-26.1.0-runtime (com.android.support:support-core-utils:26.1.0) Duplicate class android.support.v4.content.FileProvider$SimplePathStrategy found in modules support-compat-28.0.0-runtime (com.android.support:support-compat:28.0.0) and support-core-utils-26.1.0-runtime (com.android.support:support-core-utils:26.1.0) Duplicate class android.support.v4.content.MimeTypeFilter found in modules support-compat-28.0.0-runtime (com.android.support:support-compat:28.0.0) and support-core-utils-26.1.0-runtime (com.android.support:support-core-utils:26.1.0) Duplicate class android.support.v4.content.PermissionChecker found in modules support-compat-28.0.0-runtime (com.android.support:support-compat:28.0.0) and support-core-utils-26.1.0-runtime (com.android.support:support-core-utils:26.1.0) Duplicate class android.support.v4.content.PermissionChecker$PermissionResult found in modules support-compat-28.0.0-runtime (com.android.support:support-compat:28.0.0) and support-core-utils-26.1.0-runtime (com.android.support:support-core-utils:26.1.0) Duplicate class android.support.v4.graphics.ColorUtils found in modules support-compat-28.0.0-runtime (com.android.support:support-compat:28.0.0) and support-core-utils-26.1.0-runtime (com.android.support:support-core-utils:26.1.0) Duplicate class android.support.v4.graphics.drawable.IconCompatParcelizer found in modules core-1.9.0-runtime (androidx.core:core:1.9.0) and support-compat-28.0.0-runtime (com.android.support:support-compat:28.0.0) Duplicate class android.support.v4.graphics.drawable.RoundedBitmapDrawable found in modules support-compat-28.0.0-runtime (com.android.support:support-compat:28.0.0) and support-core-utils-26.1.0-runtime (com.android.support:support-core-utils:26.1.0) Duplicate class android.support.v4.graphics.drawable.RoundedBitmapDrawable21 found in modules support-compat-28.0.0-runtime (com.android.support:support-compat:28.0.0) and support-core-utils-26.1.0-runtime (com.android.support:support-core-utils:26.1.0) Duplicate class android.support.v4.graphics.drawable.RoundedBitmapDrawableFactory found in modules support-compat-28.0.0-runtime (com.android.support:support-compat:28.0.0) and support-core-utils-26.1.0-runtime (com.android.support:support-core-utils:26.1.0) Duplicate class android.support.v4.graphics.drawable.RoundedBitmapDrawableFactory$DefaultRoundedBitmapDrawable found in modules support-compat-28.0.0-runtime (com.android.support:support-compat:28.0.0) and support-core-utils-26.1.0-runtime (com.android.support:support-core-utils:26.1.0) Duplicate class android.support.v4.math.MathUtils found in modules support-compat-28.0.0-runtime (com.android.support:support-compat:28.0.0) and support-core-utils-26.1.0-runtime (com.android.support:support-core-utils:26.1.0) Duplicate class android.support.v4.os.IResultReceiver found in modules core-1.9.0-runtime (androidx.core:core:1.9.0) and support-compat-28.0.0-runtime (com.android.support:support-compat:28.0.0) Duplicate class android.support.v4.os.IResultReceiver$Stub found in modules core-1.9.0-runtime (androidx.core:core:1.9.0) and support-compat-28.0.0-runtime (com.android.support:support-compat:28.0.0) Duplicate class android.support.v4.os.IResultReceiver$Stub$Proxy found in modules core-1.9.0-runtime (androidx.core:core:1.9.0) and support-compat-28.0.0-runtime (com.android.support:support-compat:28.0.0) Duplicate class android.support.v4.os.ResultReceiver found in modules core-1.9.0-runtime (androidx.core:core:1.9.0) and support-compat-28.0.0-runtime (com.android.support:support-compat:28.0.0) Duplicate class android.support.v4.os.ResultReceiver$1 found in modules core-1.9.0-runtime (androidx.core:core:1.9.0) and support-compat-28.0.0-runtime (com.android.support:support-compat:28.0.0) Duplicate class android.support.v4.os.ResultReceiver$MyResultReceiver found in modules core-1.9.0-runtime (androidx.core:core:1.9.0) and support-compat-28.0.0-runtime (com.android.support:support-compat:28.0.0) Duplicate class android.support.v4.os.ResultReceiver$MyRunnable found in modules core-1.9.0-runtime (androidx.core:core:1.9.0) and support-compat-28.0.0-runtime (com.android.support:support-compat:28.0.0) Duplicate class android.support.v4.view.NestedScrollingChildHelper found in modules support-compat-28.0.0-runtime (com.android.support:support-compat:28.0.0) and support-core-ui-26.1.0-runtime (com.android.support:support-core-ui:26.1.0) Duplicate class android.support.v4.view.NestedScrollingParentHelper found in modules support-compat-28.0.0-runtime (com.android.support:support-compat:28.0.0) and support-core-ui-26.1.0-runtime (com.android.support:support-core-ui:26.1.0) Duplicate class android.support.v4.widget.AutoScrollHelper found in modules support-compat-28.0.0-runtime (com.android.support:support-compat:28.0.0) and support-core-ui-26.1.0-runtime (com.android.support:support-core-ui:26.1.0) Duplicate class android.support.v4.widget.AutoScrollHelper$ClampedScroller found in modules support-compat-28.0.0-runtime (com.android.support:support-compat:28.0.0) and support-core-ui-26.1.0-runtime (com.android.support:support-core-ui:26.1.0) Duplicate class android.support.v4.widget.AutoScrollHelper$ScrollAnimationRunnable found in modules support-compat-28.0.0-runtime (com.android.support:support-compat:28.0.0) and support-core-ui-26.1.0-runtime (com.android.support:support-core-ui:26.1.0) Duplicate class android.support.v4.widget.ContentLoadingProgressBar found in modules support-compat-28.0.0-runtime (com.android.support:support-compat:28.0.0) and support-core-ui-26.1.0-runtime (com.android.support:support-core-ui:26.1.0) Duplicate class android.support.v4.widget.ContentLoadingProgressBar$1 found in modules support-compat-28.0.0-runtime (com.android.support:support-compat:28.0.0) and support-core-ui-26.1.0-runtime (com.android.support:support-core-ui:26.1.0) Duplicate class android.support.v4.widget.ContentLoadingProgressBar$2 found in modules support-compat-28.0.0-runtime (com.android.support:support-compat:28.0.0) and support-core-ui-26.1.0-runtime (com.android.support:support-core-ui:26.1.0) Duplicate class android.support.v4.widget.ListViewAutoScrollHelper found in modules support-compat-28.0.0-runtime (com.android.support:support-compat:28.0.0) and support-core-ui-26.1.0-runtime (com.android.support:support-core-ui:26.1.0) Duplicate class android.support.v4.widget.NestedScrollView found in modules support-compat-28.0.0-runtime (com.android.support:support-compat:28.0.0) and support-core-ui-26.1.0-runtime (com.android.support:support-core-ui:26.1.0) Duplicate class android.support.v4.widget.NestedScrollView$AccessibilityDelegate found in modules support-compat-28.0.0-runtime (com.android.support:support-compat:28.0.0) and support-core-ui-26.1.0-runtime (com.android.support:support-core-ui:26.1.0) Duplicate class android.support.v4.widget.NestedScrollView$OnScrollChangeListener found in modules support-compat-28.0.0-runtime (com.android.support:support-compat:28.0.0) and support-core-ui-26.1.0-runtime (com.android.support:support-core-ui:26.1.0) Duplicate class android.support.v4.widget.NestedScrollView$SavedState found in modules support-compat-28.0.0-runtime (com.android.support:support-compat:28.0.0) and support-core-ui-26.1.0-runtime (com.android.support:support-core-ui:26.1.0) Duplicate class android.support.v4.widget.NestedScrollView$SavedState$1 found in modules support-compat-28.0.0-runtime (com.android.support:support-compat:28.0.0) and support-core-ui-26.1.0-runtime (com.android.support:support-core-ui:26.1.0) Duplicate class androidx.core.graphics.drawable.IconCompatParcelizer found in modules core-1.9.0-runtime (androidx.core:core:1.9.0) and support-compat-28.0.0-runtime (com.android.support:support-compat:28.0.0) Duplicate class androidx.core.internal.package-info found in modules core-1.9.0-runtime (androidx.core:core:1.9.0) and support-compat-28.0.0-runtime (com.android.support:support-compat:28.0.0) Duplicate class androidx.versionedparcelable.CustomVersionedParcelable found in modules versionedparcelable-1.1.1-runtime (androidx.versionedparcelable:versionedparcelable:1.1.1) and versionedparcelable-28.0.0-runtime (com.android.support:versionedparcelable:28.0.0) Duplicate class androidx.versionedparcelable.NonParcelField found in modules versionedparcelable-1.1.1-runtime (androidx.versionedparcelable:versionedparcelable:1.1.1) and versionedparcelable-28.0.0-runtime (com.android.support:versionedparcelable:28.0.0) Duplicate class androidx.versionedparcelable.ParcelField found in modules versionedparcelable-1.1.1-runtime (androidx.versionedparcelable:versionedparcelable:1.1.1) and versionedparcelable-28.0.0-runtime (com.android.support:versionedparcelable:28.0.0) Duplicate class androidx.versionedparcelable.ParcelImpl found in modules versionedparcelable-1.1.1-runtime (androidx.versionedparcelable:versionedparcelable:1.1.1) and versionedparcelable-28.0.0-runtime (com.android.support:versionedparcelable:28.0.0) Duplicate class androidx.versionedparcelable.ParcelImpl$1 found in modules versionedparcelable-1.1.1-runtime (androidx.versionedparcelable:versionedparcelable:1.1.1) and versionedparcelable-28.0.0-runtime (com.android.support:versionedparcelable:28.0.0) Duplicate class androidx.versionedparcelable.ParcelUtils found in modules versionedparcelable-1.1.1-runtime (androidx.versionedparcelable:versionedparcelable:1.1.1) and versionedparcelable-28.0.0-runtime (com.android.support:versionedparcelable:28.0.0) Duplicate class androidx.versionedparcelable.VersionedParcel found in modules versionedparcelable-1.1.1-runtime (androidx.versionedparcelable:versionedparcelable:1.1.1) and versionedparcelable-28.0.0-runtime (com.android.support:versionedparcelable:28.0.0) Duplicate class androidx.versionedparcelable.VersionedParcel$1 found in modules versionedparcelable-1.1.1-runtime (androidx.versionedparcelable:versionedparcelable:1.1.1) and versionedparcelable-28.0.0-runtime (com.android.support:versionedparcelable:28.0.0) Duplicate class androidx.versionedparcelable.VersionedParcel$ParcelException found in modules versionedparcelable-1.1.1-runtime (androidx.versionedparcelable:versionedparcelable:1.1.1) and versionedparcelable-28.0.0-runtime (com.android.support:versionedparcelable:28.0.0) Duplicate class androidx.versionedparcelable.VersionedParcelParcel found in modules versionedparcelable-1.1.1-runtime (androidx.versionedparcelable:versionedparcelable:1.1.1) and versionedparcelable-28.0.0-runtime (com.android.support:versionedparcelable:28.0.0) Duplicate class androidx.versionedparcelable.VersionedParcelStream found in modules versionedparcelable-1.1.1-runtime (androidx.versionedparcelable:versionedparcelable:1.1.1) and versionedparcelable-28.0.0-runtime (com.android.support:versionedparcelable:28.0.0) Duplicate class androidx.versionedparcelable.VersionedParcelStream$FieldBuffer found in modules versionedparcelable-1.1.1-runtime (androidx.versionedparcelable:versionedparcelable:1.1.1) and versionedparcelable-28.0.0-runtime (com.android.support:versionedparcelable:28.0.0) Duplicate class androidx.versionedparcelable.VersionedParcelable found in modules versionedparcelable-1.1.1-runtime (androidx.versionedparcelable:versionedparcelable:1.1.1) and versionedparcelable-28.0.0-runtime (com.android.support:versionedparcelable:28.0.0) Duplicate class androidx.versionedparcelable.VersionedParcelize found in modules versionedparcelable-1.1.1-runtime (androidx.versionedparcelable:versionedparcelable:1.1.1) and versionedparcelable-28.0.0-runtime (com.android.support:versionedparcelable:28.0.0)
# 解读 在模块 support-compat-28.0.0-runtime (com.android.support:support-compat:28.0.0) 和 support-core-utils-26.1.0-runtime (com.android.support:support-core-utils:26.1.0) 中发现重复的类 android.support.v4.app.AppLaunchChecker ... 在模块 core-1.9.0-runtime (androidx.core:core:1.9.0) 和 support-compat-28.0.0-runtime (com.android.support:support-compat:28.0.0) 中发现重复的类 android.support.v4.app.INotificationSideChannel ...
问题原因
  • 这个错误表示项目依赖环境中同时混用了AndroidX 库和 Support 库,Gradle 在构建时发现了这些重复的类定义
  1. Support 库内部发生冲突,support-compat-28.0.0support-core-utils-26.1.0等不同版本的 Support 模块间存在重复类

  2. AndroidX 库与 Support 库发生冲突,androidx.core:core:1.9.0com.android.support:support-compat:28.0.0等 AndroidX 库与 Support 库间存在重复类

处理策略
  • gradle.properties文件中添加如下内容
android.useAndroidX=true android.enableJetifier=true
  1. android.useAndroidX=true:表示项目使用 AndroidX 库

  2. android.enableJetifier=true:表示允许 Gradle 自动重写旧的第三方库的二进制文件,将其中的旧支持库引用转换为 AndroidX 引用

  • 以下是另外的一些尝试,但是无法处理该问题
dependencies{...configurations.all{resolutionStrategy{force'com.android.support:support-compat:28.0.0'force'com.android.support:support-core-utils:28.0.0'force'com.android.support:support-core-ui:28.0.0'force'com.android.support:versionedparcelable:28.0.0'force'com.android.support:loader:28.0.0'force'com.android.support:support-fragment:28.0.0'}}android{configurations{all*.exclude group:'com.android.support',module:'support-compat'}}}
版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/7/13 19:17:17

百万在线长连接架构实战:社交私信、直播弹幕实时消息推送解决方案

前言社交APP私信、直播间弹幕是互联网典型的海量长连接、高并发实时推送场景。业务高峰期平台可轻松达到50万~百万同时在线,海量用户常驻在线、持续持有客户端连接,对服务端连接承载、消息实时性、带宽利用率、数据一致性要求极高。很多后端同…

作者头像 李华
网站建设 2026/7/13 19:16:54

tochd:游戏镜像格式转换的自动化解决方案与技术实现深度解析

tochd:游戏镜像格式转换的自动化解决方案与技术实现深度解析 【免费下载链接】tochd Convert game ISO and archives to CD/DVD CHD for emulation on Linux. 项目地址: https://gitcode.com/gh_mirrors/to/tochd 还在为模拟器游戏文件的格式混乱而困扰吗&am…

作者头像 李华
网站建设 2026/7/13 19:16:32

免费专业级Photoshop Linux安装器:5分钟轻松搞定

免费专业级Photoshop Linux安装器:5分钟轻松搞定 【免费下载链接】Photoshop This program written in C will help you to automatically install everything you need and configure it so that you can run Photoshop on your Linux without problems. 项目地址…

作者头像 李华
网站建设 2026/7/13 19:11:51

深挖实体经营痛点,2026门店管理系统多维度选型解析

线下实体门店在2026年全面进入数智化深耕阶段,多门店数据割裂、库存管控混乱、会员复购乏力等问题,成为制约商户发展的主要阻碍。市面上各类门店管理系统功能侧重各有不同,商户需要结合门店规模、业态类型与长期运营规划综合挑选。本文将结合…

作者头像 李华
网站建设 2026/7/13 19:11:11

习得性无助 VS 非习得性无助

第一层:什么是习得性无助? 经典过程是: 努力↓ 失败↓ 继续努力↓ 继续失败↓ 开始相信: "我改变不了。"注意。 真正学到的不是: 失败。 而是:行动不会改变结果。这是我们前面一直讨论的&#xf…

作者头像 李华