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

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.kler.cn/news/356752.html

相关文章:

  • 博客|基于springBoot的精简博客系统设计与实现(附项目源码+论文+数据库)
  • [机器视觉]basler相机使用SN编号打开相机和采集
  • Android中的MVP模式
  • 【LeetCode】每日一题 2024_10_16 最小元素和最大元素的最小平均值(排序、模拟)
  • Android 开发 TabLayout 自定义指示器长度
  • 深入学习二叉树(BinaryTree)(纯小白进)
  • SpringBoot智能推荐:健康生活新体验
  • Lua表(Table)
  • MySQL程序介绍<一>
  • 侏罗纪公园不再是电影了吗?
  • 快速了解K8S几种网络实现
  • 代码复现(五):GCPANet
  • 高数导数积分知识点归纳
  • 使用Javascript实现一个Cron表达式的函数
  • 【Tinymce】富文本编辑器在vue项目中的使用;引入付费格式刷,上传视频、图片
  • IE11删除hao360主页
  • element plus的el-select分页
  • 图论day62|拓扑排序理论基础、117.软件构建(卡码网)、最短路径之dijkstra理论基、47.参加科学大会(卡码网 第六期模拟笔试)
  • 【C++篇】类与对象的秘密(上)
  • MongoDB 如何做mapreduce