Android Studio 在哪里保存 ProGuard 映射文件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25724645/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Where does Android Studio save the ProGuard mapping file?
提问by CQM
In Android Studio, where are the ProGuard mapping files generated after compiling a signed APK?
在Android Studio中,编译签名APK后生成的ProGuard映射文件在哪里?
I'm not sure if it isn't working or if I just forgot the file path, and my compulsory Google/Stack Overflow search did not answer this
我不确定它是否不起作用,或者我是否只是忘记了文件路径,而且我的强制 Google/Stack Overflow 搜索没有回答这个问题
回答by Scott Barta
It should be located at build/outputs/proguard/release/mapping.txt
in your application module's directory.
它应该位于build/outputs/proguard/release/mapping.txt
您的应用程序模块的目录中。
In the latest version of ProGuard and Android Studio, the file is located at build/outputs/mapping/release/mapping.txt
.
在最新版本的 ProGuard 和 Android Studio 中,该文件位于build/outputs/mapping/release/mapping.txt
.
回答by Tom
For me they are at 'build/outputs/mapping/release'
对我来说,他们在 'build/outputs/mapping/release'
回答by Mark
I found it cleaner to configure proguard to write the mapping.txt file to a location outside of the build/
directory tree, so that it could be more conveniently checked into version control.
我发现将 proguard 配置为将 mapping.txt 文件写入build/
目录树之外的位置更简洁,以便可以更方便地将其签入版本控制。
To achieve this, put this in your proguard-rules.pro
file:
为此,请将其放入您的proguard-rules.pro
文件中:
-printmapping mapping.txt
This will (most likely) place it in the same directory as your proguard-rules.pro
file. Ultimately, you probably want to write it to the same directory as your APK file and with an equivalent name (which might include flavor, build type etc).
这将(很可能)将它放在与您的proguard-rules.pro
文件相同的目录中。最终,您可能希望将其写入与您的 APK 文件相同的目录并使用等效名称(可能包括风味、构建类型等)。
Note: in my experience, this is notoverruled by the proguard template file (which was suggested by a commenter to another answerhere).
注意:根据我的经验,这不会被 proguard 模板文件否决(这是由评论者对这里的另一个答案提出的建议)。
UPDATE: If you have multiple product flavors, then this is a much better solution: https://stackoverflow.com/a/31116608/444761
更新:如果您有多种产品口味,那么这是一个更好的解决方案:https: //stackoverflow.com/a/31116608/444761
回答by Clive Jefferies
I found that it was not being generated, so I added this to the rules file
我发现它没有被生成,所以我将它添加到规则文件中
-printmapping build/outputs/mapping/release/mapping.txt
回答by WitVault
Its quite late to answer this question but just in case someone need my answer.
回答这个问题已经很晚了,但以防万一有人需要我的答案。
Location of Mapping file to deobfuscate:
要反混淆的映射文件的位置:
ProGuard saves the file in the app app/build/outputs/mapping/FLAVOR/release/mapping.txt
ProGuard 将文件保存在 app app/build/outputs/mapping/FLAVOR/release/mapping.txt
Generally in debug mode you don't need the mapping file because there generally obfuscation is disabled. If it is not that case then make sure in build.gradle file you have below code for debug variant.
通常在调试模式下您不需要映射文件,因为通常禁用混淆。如果不是这种情况,请确保在 build.gradle 文件中具有以下调试变体代码。
debug {
minifyEnabled false
debuggable true
}
Some Gotchas:
一些问题:
mapping.txt file gets overwritten every time you create a release build with ProGuard, so first take backup of that file before creating a new release. It will help to obfuscated stack trace from an older version of your app.
每次使用 ProGuard 创建发布版本时,mapping.txt 文件都会被覆盖,因此请先备份该文件,然后再创建新版本。这将有助于混淆旧版本应用程序的堆栈跟踪。
Apart from that there are two ways to obfuscate your code :
除此之外,还有两种方法可以混淆您的代码:
1. Upload your mapping.txt file to Google play Console:
1. 将您的 mapping.txt 文件上传到 Google Play 控制台:
When publishing your app on Google Play, you can upload the mapping.txt file for each version of your APK. Then Google Play will deobfuscate incoming stack traces from user-reported issues so you can review them in the Google Play Console.
在 Google Play 上发布您的应用时,您可以为每个 APK 版本上传 mapping.txt 文件。然后,Google Play 将对来自用户报告的问题的传入堆栈跟踪进行反混淆处理,以便您可以在 Google Play 控制台中查看它们。
2. Use local sdk tool retrace.sh/retrace.bat:
2.使用本地sdk工具retrace.sh/retrace.bat:
Some times you want to run the release version of your app(by changing build variant to release and running it) to cross check and fix the errors so that it does not happens in production ( when released to play-store).
有时您想运行应用程序的发布版本(通过将构建变体更改为发布并运行它)来交叉检查和修复错误,以便它不会在生产中发生(发布到游戏商店时)。
To convert an obfuscated stack-trace to a readable one yourself, use the retrace script (retrace.bat on Windows; retrace.sh on Mac/Linux).
要将混淆的堆栈跟踪转换为自己可读的堆栈跟踪,请使用回溯脚本(Windows 上的 retrace.bat ;Mac/Linux 上的 retrace.sh)。
It is located in the <sdk-root>/tools/proguard/bin/
directory.
它位于<sdk-root>/tools/proguard/bin/
目录中。
<sdk-root>
is the place where your all android libraries and sdks were installed.
<sdk-root>
是安装所有 android 库和 sdks 的地方。
The script takes the mapping.txt file and your stack trace, producing a new, readable stack trace.
该脚本采用 mapping.txt 文件和您的堆栈跟踪,生成一个新的、可读的堆栈跟踪。
Command Syntax:
命令语法:
retrace.bat|retrace.sh [-verbose] mapping.txt [<stacktrace_file>]
For example:
例如:
retrace.bat -verbose mapping.txt obfuscated_trace.txt
I prefer local version of obfuscating as is quite handy to pre-check production errors.
我更喜欢本地版本的混淆,因为它非常方便预先检查生产错误。
I hope it helps.
我希望它有帮助。
回答by Faisal Shaikh
I am using version Android Studio 2.2.2. For me it's located in the following locations:
我使用的是Android Studio 2.2.2版本。对我来说,它位于以下位置:
For debug:
\app\build\outputs\mapping\debug\mapping.txt
对于调试:
\app\build\outputs\mapping\debug\mapping.txt
For release:
\app\build\outputs\mapping\release\mapping.txt
发布:
\app\build\outputs\mapping\release\mapping.txt
回答by philo
Because I'm dumb and get lost even when somebody tells me where the file is:
因为我很笨,即使有人告诉我文件在哪里,我也会迷路:
cd StudioProjects/fooProject
find . -name "mapping.txt" | xargs less