Android ProGuard 混淆库:保持类不起作用 [英] Android ProGuard obfuscation of library: keep class not working

查看:63
本文介绍了Android ProGuard 混淆库:保持类不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

简介:我在 AS 1 项目中有 2 个模型:

Intro: I have in AS 1 project with 2 models:

  1. 带有一些公共 API 类"的 Android 库项目
  2. Android APP依赖于上述库(库模块在依赖列表中)

任务:我想混淆我的库项目,因为我想将它公开为公共 SDK 但保护我的代码......

Task: I want to obfuscate my library project because I want to expose it as public SDK but keep my code protected...

我做了什么:所以我制定了自定义 ProGuard 规则:

What I did: So I made custom ProGuard rules:

-dontshrink
-dontoptimize
-dontpreverify
-keep class com.org.my_public_api_class_name

我跳过所有其他阶段,以消除错误所在的仅混淆阶段.

I skip all other stages in order to eliminate where the bug is to only obfuscation stage.

结果: APP 模块的构建失败,出现类似

Result: Build of the APP module fails with errors like

错误:找不到符号类 my_public_api_class_name

在我看来,问题是混淆没有跳过我想要的课程,所以现在他有一些毫无意义的名字,因此在我使用他的 APP 中,原始名字不存在.

It seems for me that the problem is that the obfuscation NOT skipped the class I wanted to, so now he has some meaningless name and therefore in the APP, where I'm using him, The original name not exist.

谢谢,

推荐答案

要从混淆中排除您的类,请尝试以下操作:

To exclude your class from obfuscation, try this:

 -keep class com.org.my_public_api_class_name**
 -keepclassmembers class com.org.my_public_api_class_name** {*;}

这篇关于Android ProGuard 混淆库:保持类不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆