当前位置: 首页 > news >正文

Missing classes detected while running R8报错解决方案

Android 打包release版本时报错如下:

> Task :printlib:minifyReleaseWithR8 FAILED
AGPBI: {"kind":"error","text":"Missing classes detected while running R8. Please add the missing classes or apply additional keep rules that are generated in /Users/mac/Documents/code/PrintDemo/printlib/build/outputs/mapping/release/missing_rules.txt.","sources":[{}]}
AGPBI: {"kind":"error","text":"Missing class com.hw.hwbaselib.adapter.BaseRvAdapter (referenced from: void com.hw.printlib.adapter.BluetoothDeviceAdapter.<init>() and 1 other context)","sources":[{}],"tool":"R8"}Missing classes detected while running R8. Please add the missing classes or apply additional keep rules that are generated in /Users/mac/Documents/code/PrintDemo/printlib/build/outputs/mapping/release/missing_rules.txt.Missing class com.hw.hwbaselib.adapter.BaseRvAdapter (referenced from: void com.hw.printlib.adapter.BluetoothDeviceAdapter.<init>() and 1 other context)

解决方案:
查看AGP依赖的版本,项目中依赖的AGP版本如下:

[versions]
agp = "8.5.1"

这个版本太高了,容易出现混淆打包的问题,修改成如下版本就可以解决问题了

[versions]
agp = "8.3.2"

如果改完了还是报错,如下:

> Task :app:minifyReleaseWithR8 FAILED
AGPBI: {"kind":"error","text":"Missing classes detected while running R8. Please add the missing classes or apply additional keep rules that are generated in /Users/mac/Documents/code/PrintDemo/app/build/outputs/mapping/release/missing_rules.txt.","sources":[{}]}
AGPBI: {"kind":"error","text":"Missing class javax.annotation.Nullable (referenced from: okio.Segment okio.Buffer.head and 2 other contexts)","sources":[{}],"tool":"R8"}Missing classes detected while running R8. Please add the missing classes or apply additional keep rules that are generated in /Users/mac/Documents/code/PrintDemo/app/build/outputs/mapping/release/missing_rules.txt.Missing class javax.annotation.Nullable (referenced from: okio.Segment okio.Buffer.head and 2 other contexts)

需要把上述报错中的这句话中的txt文件中的内容,复制到当前module的混淆配置文件中,

Missing classes detected while running R8. Please add the missing
classes or apply additional keep rules that are generated in
/Users/mac/Documents/code/PrintDemo/app/build/outputs/mapping/release/missing_rules.txt

在电脑中找到这个文件,打开,如下:
我的这个missing_rules.txt文件中,内容是这样的,每个项目可能不一样,直接复制里面内容,放到混淆文件中就可以了

# Please add these rules to your existing keep rules in order to suppress warnings.
# This is generated automatically by the Android Gradle plugin.
-dontwarn javax.annotation.Nullable

最后打包就成功了
在这里插入图片描述

http://www.lryc.cn/news/467507.html

相关文章:

  • 智能指针
  • 通过DevTools逃离Chrome沙盒(CVE-2024-6778和CVE-2024-5836)
  • 手持无人机飞手执照,会组装调试入伍当兵有多香!
  • 项目经理好累好烦啊,不想干了....
  • 论技术人员“技术人格”的重要意义
  • Kafka异常重试方案小记
  • 非页面缓冲池占用过高处理方法
  • 【Linux】进程信号(下)
  • FlinkCDC 实现 MySQL 数据变更实时同步
  • JavaWeb——Maven(4/8):Maven坐标,idea集成-导入maven项目(两种方式)
  • 实现uniapp天地图边界范围覆盖
  • 思科网络设备命令
  • Egg.js使用ejs快速自动生成resetful风格的CRUD接口
  • 自动化抖音点赞取消脚本批量处理
  • 基于YOLOv8深度学习的智能车牌检测与识别系统【python源码+Pyqt5界面+数据集+训练代码】目标检测、深度学习实战
  • qt QGraphicsGridLayout详解
  • 数字处理系列
  • 基于开源Jetlinks物联网平台协议包-MQTT自定义主题数据的编解码
  • 【Python】Python2.7升级Python3
  • Python 内置函数 round() 详解
  • JavaScript入门中-流程控制语句
  • kconfig语法(一)
  • 十七、行为型(命令模式)
  • 原材料供应商的GRS认证证书过期了怎么办?
  • C++编程:实现一个基于原始指针的环形缓冲区(RingBuffer)缓存串口数据
  • LangChain 创始人万字科普:手把手教你设计 Agent 用户交互
  • Docker 用例:15 种最常见的 Docker 使用方法
  • 若依 RuoYi4.6.0 代码审计
  • C语言入门-选择结构
  • Legion拯救者 刃7000K-26IAB联想台式机T5 26IAB7(90SU,90SV,90SW,90SX)原厂Windows11系统镜像下载