如何为我的 Android 应用程序添加代码混淆

2024-04-24

如何为 android apk 添加代码混淆。我用了proguard但仍然看到来自应用程序的代码decompiler.

我像这样添加了progruad

release {
      debuggable true
      minifyEnabled true
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}

反编译后它可以看到我的所有代码和类。反编译后 https://i.stack.imgur.com/CiiVQ.png

我的 Proguard 文件在此输入图像描述 https://i.stack.imgur.com/7bEu0.png


使用下面的代码来获取您的解决方案。

android {
    buildTypes {
            debug {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
                zipAlignEnabled true
                shrinkResources false
            }
            release {
                debuggable false
                // Enables code shrinking, obfuscation, and optimization for only
                // your project's release build type.
                minifyEnabled true

                // Includes the default ProGuard rules files that are packaged with
                // the Android Gradle plugin. To learn more, go to the section about
                // R8 configuration files.
                proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'

                zipAlignEnabled true

                // Enables resource shrinking, which is performed by the
                // Android Gradle plugin.
                shrinkResources true
            }
        }
     }

TODO 更新 proguard

#Specifies not to ignore non-public library classes.
-dontskipnonpubliclibraryclasses

#Specifies not to ignore package visible library class members
-dontskipnonpubliclibraryclassmembers

-optimizationpasses 5
#Specifies that the access modifiers of classes and class members may have become broad during processing. This can improve the results of the optimization step.
-allowaccessmodification
#Specifies that interfaces may be merged, even if their implementing classes don't implement all interface methods. This can reduce the size of the output by reducing the total number of classes.
-mergeinterfacesaggressively

#Specifies to apply aggressive overloading while obfuscating. Multiple fields and methods can then get the same names, This option can make the processed code even smaller
#-overloadaggressively

#Specifies to repackage all packages that are renamed, by moving them into the single given parent package
-flattenpackagehierarchy

#Specifies to repackage all class files that are renamed, by moving them into the single given package. Without argument or with an empty string (''), the package is removed completely.
-repackageclasses

#For example, if your code contains a large number of hard-coded strings that refer to classes, and you prefer not to keep their names, you may want to use this option
-adaptclassstrings
#Specifies the resource files to be renamed, all resource files that correspond to class files are renamed
-adaptresourcefilenames

#Specifies the resource files whose contents are to be updated. Any class names mentioned in the resource files are renamed
-adaptresourcefilecontents

#Specifies not to verify the processed class files.
#-dontpreverify

-verbose

#Specifies to print any warnings about unresolved references and other important problems, but to continue processing in any case.
-ignorewarnings

# ADDED
#-dontobfuscate
#-useuniqueclassmembernames

# For enumeration classes, see http://proguard.sourceforge.net/manual/examples.html#enumerations
-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

-assumenosideeffects class android.util.Log {
    public static boolean isLoggable(java.lang.String, int);
    public static *** d(...);
    public static *** v(...);
    public static *** i(...);
    public static *** w(...);
    public static *** e(...);
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何为我的 Android 应用程序添加代码混淆 的相关文章

随机推荐

  • asp.net 2.0 全局主题无法在新的 Windows Server 2008 上运行

    我们正在将 net 2 0 网站从带有 IIS6 的 Windows 2003 服务器 32 位 迁移到带有 IIS7 的 Windows Server 2008 64 位 机器 我似乎无法让全球主题发挥作用 与我们的旧服务器相同的内容 目
  • 如何使用 Log4net RolloverFileAppender 在应用程序启动时强制翻转?

    在我们的应用程序中配置 Log4Net 以使用带日期标记的名称和 10Meg 文件大小限制 这会在午夜以及每当达到 10Meg 限制时自动转存到新文件 我还想在每次启动 或关闭 应用程序时将日志记录到一个新文件 我可以获得所有三种翻转行为吗
  • 在 OSX 下将许可证文件附加到 dmg

    伙计们 我可以使用任何命令行将许可证文件附加到 dmg 吗 非常感谢 我在编辑器上遇到了问题 所以如果您在文本中看到 奇怪的事情 请原谅我 我为你找到了一篇博客文章 链接在这里 http thehobbsfamily net archive
  • 无法将应用内购买的托管内容上传到 iTunesConnect

    我正在尝试上传托管内容以进行应用内购买 但到目前为止我尚未成功 我之前使用 Application Loader 为我的应用程序上传了大约 100 个应用程序内购买包 我以前可以毫无问题地上传这些包 现在我注意到最新版本的应用程序加载器 版
  • Python浮点数比较

    我只是回顾了 Python 的一些基础知识 并且有一个关于比较浮点数的棘手问题 2 2 3 0 6 6 3 3 2 0 6 6 I thought these should both return a False However the s
  • XSLT:提取唯一属性值

    请帮忙 我是 XSLT 新手 我正在尝试将一种 XML 格式转换为另一种格式 我需要提取唯一的属性值并将这些值转换为新的格式 下面的示例 XML 显示了原始格式和新 目标格式 我花了很长时间尝试这样做 但没有任何乐趣 有人可以帮忙或给我一些
  • asp.net mvc验证必须是数字自定义错误

    我是 ASP NET 的新手 我遇到了一个问题 当用户在编辑器中为小数字段插入数字以外的内容时 他们会收到错误 字段名称 不是数字 但我不希望他们收到此消息 我希望他们收到另一条消息 对于必需的和范围验证器 我对此没有任何问题 我有什么办法
  • Spring Boot 在 ServerOAuth2AuthorizedClientExchangeFilterFunction 中向 WebClient 请求添加附加属性

    我正在尝试实现 client credentials 授予以在我的 Spring Boot 资源服务器中获取令牌 我在用Auth0作为授权服务器 他们似乎需要在请求正文中添加一个名为 audience 的额外参数 我尝试通过邮递员提出请求并
  • 使用 XSLT 重命名 XML 元素

    我需要更改原始 XML 中的一些元素名称 我正在尝试使用 XSLT 来做到这一点 但无法让它工作 下面是一个 XML 示例 section Jabber section
  • 使用 FileSystemObject write() 写入二进制数据

    我正在使用 FileSystemObject 在 Javascript 中开发一个函数 我只需将我们提供的二进制数据写入文件即可 这是我的职责 function exportFile data var fso f2 fso new Acti
  • 在Android中设置相机对焦区域

    在几个教程和示例之后 我提出了下一个算法来将相机焦点设置在特定点上 问题是相机完全忽略该点并执行正常的整体焦点 而不是我指定的矩形区域 算法中还有什么我遗漏的吗 这已经在多款 Android 4 0 及以上版本的手机上进行了测试 因此这些设
  • Visual Studio 2010 Pro 包括 LightSwitch。如何?

    我看到了 VS2010 Proincludes http social msdn microsoft com Forums en US isvpartneringwithmsft thread 61f54bfa 41ae 4ea1 a871
  • eigen(corr) 中的错误:制作“相关矩阵圆图”时“x”中存在无限值或缺失值

    我想制作一个如下所示的相关矩阵 然而 R一直告诉我 Error in eigen corr infinite or missing values in x 相关矩阵圆 http gallery r enthusiasts com graph
  • 使用 Zeep 通过代理访问 SOAP 时更改服务 URL

    在我的应用程序中 我需要访问内部 公司 Soap API 到目前为止 我已经使用 Zeep 进行此访问 但现在访问必须通过代理 并且API的实际地址必须转换为代理的虚拟地址 创建 Zeep 客户端也可以正常工作 并且我可以访问 WSDL 文
  • 想要将 ColeDateTime 转换为 CTime

    我正在从数据库中读取日期时间ColeDateTime格式 我想将其转换为CTime获取日期 月份 年份和时间 CString repDt this will hold the datetime which i read from Datab
  • 如何使用 cmake -v 调用来帮助查找链接器错误

    我从 android studio NDK 构建中收到以下错误 Error error linker command failed with exit code 1 use v to see invocation 如何按照错误提示 使用 v
  • DotNetNuke 6 支持 Ajax 控制工具包吗?

    有人使用 Ajax 控制工具包在 DNN 6 中成功运行了模块吗 当我们从 DNN 5 x 迁移到 6 x 时 我的模块停止工作 模块编译没有错误 但我收到客户端脚本错误 AjaxControlToolkit 需要 ASP NET Ajax
  • 将矩阵从 3d 重塑为 2d 并保持特定顺序

    我想将 4x3x5 形式的矩阵调整为 20x3 的二维矩阵 但同时保留顺序 如下所示 功能reshape 不保留这个特定的顺序 我怎样才能以最简单的方式实现这一点 让我们一劳永逸地解决这些跨越三维的串联和切割问题吧 第一部分 3D 到 2D
  • 为什么Data.Hashmap中没有mapKeys?

    我想使用诸如mapKeys to map仅限按键 即有一个功能mapKeys in Data Map 但没有类似物Data Hashmap 此外 在Data Hashmap我没有发现任何有关操作按键的信息 是否只有不完整之处Data Has
  • 如何为我的 Android 应用程序添加代码混淆

    如何为 android apk 添加代码混淆 我用了proguard但仍然看到来自应用程序的代码decompiler 我像这样添加了progruad release debuggable true minifyEnabled true pr