如何在Android Studio中启用ProGuard模糊处理? [英] How to enable ProGuard obfuscation in Android Studio?
问题描述
我必须通过在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的哈希值
Error:Execution failed for task ':app:packageRelease'. Unable to compute hash of 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
基本上,我是通过以下方式解决此问题的:我试图在发布"模式下运行我的应用程序,并在此处遇到类似此人的错误:
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模糊处理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!