如何使用JACK编译器执行缩小和模糊处理? [英] How to perform minification and obfuscation with the JACK compiler?
问题描述
Google已发布了针对Android的新 JACK编译器的测试版本. Android Studio 2.1开发人员.
Google has released a test version of their new JACK compiler for Android developers with Android Studio 2.1.
我的问题是,我们如何使用JACK对APK启用混淆功能?下面的文章说,JACK在本地执行混淆处理,而不再需要Proguard:
My question is, how do we enable obfuscation for the APK with JACK? The article below says that JACK performs obfuscation natively and eliminates the need for Proguard:
以下文章说,JACK使用Proguard配置文件(即.pro
文件)来执行混淆处理:
Whereas the following article says that JACK makes use of Proguard configuration files (i.e. the .pro
file) for performing obfuscation:
它也说
在此过程中,杰克还处理任何请求的代码缩小(缩小和/或混淆).
During this process Jack also handles any requested code minification (shrinking and/or obfuscation).
这到底是什么意思?我们是否必须使用minifyEnabled
选项并定义一个包含Proguard选项的.pro
文件?
What exactly does this mean? Do we have to use the minifyEnabled
option and define a .pro
file containing the Proguard options?
摘要:
-
我们到底如何使用JACK启用混淆?我们可以吗 绕过Proguard的使用,还是Proguard在 混淆过程,即使我们使用JACK进行编译?
How exactly do we go about enabling obfuscation with JACK? Can we bypass the use of Proguard, or does Proguard play a de-facto role in the obfuscation process, even if we compile with JACK?
JACK当前是否支持混淆,它是否可用 在稳定的(即非Beta/canary)Android Studio版本中?
Does JACK currently support obfuscation or not, and is it available in a stable (i.e. non-beta/canary) version of Android Studio?
注意:
我已经介绍了以下帖子:
I have already referred the following posts:
更多参考文献:
-
更新:
The answer by Matt Insko is helpful, but I would like more detail, and a more precise, canonical answer.
推荐答案
J.A.C.K.最新版本的Gradle插件(v2.1.0)中似乎不支持混淆.
J.A.C.K. obfuscation does not appear to be supported in the latest released Gradle Plugin (v2.1.0).
如果在使用最新的v2.1.0插件时启用了JACK,它将告诉您
Jack requires Build Tools 24.0.0 or later
要求您使用预览工具.If you enable JACK when using the latest v2.1.0 plugin, it will tell you
Jack requires Build Tools 24.0.0 or later
requiring you to use the preview tools.使用android gradle v2.2.0-alpha1,Build Tools-v24rc4,Platform Tools-v24rc3和Sdk Tools-v25.1.7rc1,我能够对JACK进行混淆.
Using android gradle v2.2.0-alpha1, Build Tools-v24rc4, Platform Tools-v24rc3, and Sdk Tools-v25.1.7rc1 I was able to get obfuscation to be performed by JACK.
在
defaultConfig
内部启用后,它抱怨Minifying the variant used for tests is not supported when using Jack.
,因为minifyEnabled true
是在debug
版本中配置的.When enabled inside
defaultConfig
it complainedMinifying the variant used for tests is not supported when using Jack.
, becauseminifyEnabled true
was configured in thedebug
build.因此,我创建了一个自定义构建类型并在其中启用它:
So, I created a custom build type and enabled it there:
buildTypes { ... custom { minifyEnabled true proguardFiles 'proguard-android-JACK.txt-2.2.0-alpha1' jackOptions { enabled true } }
使用
proguardFiles getDefaultProguardFile('proguard-android.txt')
时出现问题.错误提示为:com.android.jack.api.v01.ConfigurationException: Error while parsing ...
,.因此,我删除了它抱怨的行,然后手动指定了修改后的配置文件.There was a problem when using
proguardFiles getDefaultProguardFile('proguard-android.txt')
. It errorred with:com.android.jack.api.v01.ConfigurationException: Error while parsing ...
, . So, I just removed the lines it complained about and then just manually specified my modified configuration file.这篇关于如何使用JACK编译器执行缩小和模糊处理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!