问题描述
我必须通过在 Android Studio 中启用 Proguard 混淆来保护我的应用程序.我已经搜索了如何应用它的过程,但我没有得到任何明确的解决方案.当我尝试时,我总是遇到错误.那么谁能告诉我在我的应用中应用它的明确步骤吗?
I have to protect my app by enabling Proguard obfuscation in Android Studio. I have searched for the process of how to apply it but i did not get any clear solution. When i try it, i always get an error. So can anyone tell me the clear steps to apply it in my app?
我按照以下步骤进行操作:
I am doing this by the following steps:
在 Android Studio 中,打开一个 Android 项目.
In Android Studio, open up an Android project.
更改为项目视图.
更改以下行:
minifyEnable false
到 minifyEnable true
设置 ProGuard 规则(可选)
Set ProGuard Rules(optional)
4.1 在项目视图中,选择 proguard-rules.pro 文件.
4.1 In Project View, select the proguard-rules.pro file.
4.2 添加以下几行以告诉 ProGuard 不要混淆某些类.
4.2 Add in the following lines to tell ProGuard not to obfuscate certain classes.
-keepclassmembers class com.dom925.xxxx
{
public *
}
我按照步骤得到的错误是
错误:任务:app:packageRelease"的执行失败.无法计算 D:\Android\Pojectname\app\build\intermediates\classes-proguard\release\classes.jar 的哈希
推荐答案
我发现了问题:
为您的项目打开 proguard-rules.pro 并将其添加到底部:
Open up the proguard-rules.pro for your project and add this to the bottom:
-dontwarn java.nio.file.Files
-dontwarn java.nio.file.Path
-dontwarn java.nio.file.OpenOption
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
基本上我是如何解决这个问题的,我试图在发布"模式下运行我的应用程序,但遇到了一堆类似于这里的人的错误:https://github.com/square/okio/issues/144
Basically how I solved it was this I tried to run my app in 'release' mode and got a bunch of errors similar to this guy here: https://github.com/square/okio/issues/144
我几乎按照他说的去做并修复了它.
I pretty much followed what he said and fixed it.
希望这可以帮助其他人生成他们的 APK!
Hope this can help others with generating their APK's!
在此处访问更多详细信息:
visit more detail here :
错误:任务 ':app:packageRelease 执行失败'.>无法计算/../AndroidStudioProjects/../classes.jar
这篇关于如何在 Android Studio 中启用 ProGuard 混淆?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!