简体   繁体   English

在Android上启用Proguard失败

[英]enabling proguard on android failing

i am trying to protect my apk file by using proguard to prevent hackers from easily decompiling my code. 我试图通过使用proguard来保护我的apk文件,以防止黑客轻易地反编译我的代码。 I have followed many tutorials online on how to do this but my application crushes when i follow the advice online. 我已经在网上关注了很多有关如何执行此操作的教程,但是当我遵循在线建议时,我的应用程序崩溃了。 The tutorials i have followed are on: 我遵循的教程在:

Enabling ProGuard in Eclipse for Android 在Eclipse中为Android启用ProGuard

http://proguard.sourceforge.net/manual/examples.html#androidapplication http://proguard.sourceforge.net/manual/examples.html#androidapplication

http://dominoc925.blogspot.com/2013/12/how-to-obfuscate-android-apk-file-using.html http://dominoc925.blogspot.com/2013/12/how-to-obfuscate-android-apk-file-using.html

The project.properties file in my source directory looks like : 我的源目录中的project.properties文件如下所示:

# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties:     sdk.dir, user.home):
proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

# Project target.
target=android-18
android.library.reference.1=..\\appcompat_v7
android.library.reference.2=../../adt-bundle-windows-x86_64-20140702/sdk/extras/google    /google_play_services/libproject/google-play-services_lib

When i attempt to Export the signed apk , the following error is displayed in the console: 当我尝试导出签名的apk时,控制台中显示以下错误:

[2014-11-14 12:41:18 - SMART calculator] Proguard returned with error code 1. See console
[2014-11-14 12:41:18 - SMART calculator] proguard.ParseException: Unknown option '(' in argument number 14
[2014-11-14 12:41:18 - SMART calculator]    at proguard.ConfigurationParser.parse(ConfigurationParser.java:191)
[2014-11-14 12:41:18 - SMART calculator]    at proguard.ProGuard.main(ProGuard.java:484)
[2014-11-14 12:41:29 - SMART calculator] Proguard returned with error code 1. See console

line 14 is the line target=android-18 in the project.properties file. 第14行是project.properties文件中的target = android-18行。

can someone please help me fix this error that i am getting. 有人可以帮我解决这个错误。 :)D :)D

proguard.config=proguard-project.txt

用这个代替

proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

I have found a quick fix. 我找到了快速解决方案。 Un-comment the line 取消注释行

proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

in the project.properties file ; 在project.properties文件中; clean your project ; 清理你的项目; compile and run/load your project for about 10 times onto your test device. 将您的项目编译并运行/加载大约10次到测试设备上。 After a while, a folder named Proguard will appear in your main directory and there will be 4 text files inside of it. 片刻之后,一个名为Proguard的文件夹将出现在您的主目录中,并且其中有4个文本文件。 Do not temper with this folder. 不要使用此文件夹。 When you now want to export your apk, comment the above line & your apk will be exported without you encountering any erroes. 现在,当您要导出apk时,请在上面的行中添加注释,这样一来,您的apk将被导出,而不会遇到任何错误。 I tried to decompile the apk i exported but the code seems obstructed with Proguard and is very difficult to reverse engineer. 我试图反编译导出的apk,但是Proguard似乎阻止了该代码,并且很难进行反向工程。

This is a very weird solution but it has worked for my project. 这是一个非常奇怪的解决方案,但对我的项目有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM