forked from amahule/aws-sdk-for-android
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Proguard.html
126 lines (117 loc) · 5.47 KB
/
Proguard.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<html>
<head>
<title>Using Proguard with the AWS SDK for Android</title>
<style type="text/css">
table.sample {
border-width: 2px;
border-spacing: 5px;
border-style: dashed;
border-color: cornflowerblue;
}
table.sample td {
padding: 5px;
}
table.sample tr {
padding: 5px;
}
</style>
</head>
<body style="padding: 10px">
<h1>Using Proguard with the AWS SDK for Android</h1>
<p> Proguard is an open source project whose aim is to help Java developers shrink, optimize, and
obfuscate their Java code. With storage on mobile devices at a premium, Proguard has
become a popular option for Android developers looking to minimize the size of their
apps and also protect their code from prying eyes. You can learn more about Proguard and
its features at the project's <a href="http://proguard.sourceforge.net/">official
site</a>. </p>
<p> Starting with version 1.3.0 of the AWS SDK for Android, AWS will be actively supporting users
who want to make use of Proguard in their Android projects. This article discusses how
developers can optimally configure Proguard to shrink, optimize, and obfuscate their
code and still use the AWS SDK for Android for all services it supports. </p>
<h2>Creating a Proguard Config</h2>
<p> Proguard is now integrated into the Eclipse IDE by means of the ADT plug-in. Starting with ADT
versions 17 and later, a default config ships with the toolkit and can be included in
your Android app. A project customization file <i>proguard-project.txt</i> will also be
created where additional options can be supplied as needed. </p>
<p> If you are adding Progaard to an existing app, you can place your <i>proguard-project.txt</i> anywhere
in the project folder, but typically it is placed at the root of your project, alongside
the <i>AndroidManifest.xml</i> and
<i>project.properties</i> files.
</p>
<p>
Regardless of whether you created the file yourself or used the default
config when you created a new project, you still
need to enable Proguard for your app. As noted on the <a
href="http://tools.android.com/recent/proguardimprovements">Android
Tools Project Site</a>, you do this by adding a line similar to the following in
your <i>project.properties</i> file:
</p>
<table class="sample"><tr><td align="left" >
<pre>proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt</pre>
</td></tr>
</table>
<p>
If you did not create your <i>proguard-project.txt</i> file at the root of
your project directory, you need to supply the path to the file
as well.
</p>
<table class="sample"><tr><td align="left" >
<pre>proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:<path_to_proguard>/proguard-project.txt</pre>
</td></tr>
</table>
<p> You may also choose to completely override the default proguard configuration as supplied by ADT
by simply excluding it from your project.properties. You can than copy the portions of
the default <i>proguard-android.txt</i> you want into your <i>proguard-project.txt</i>
<b>Note:</b> This is not recommended by the ADT developers and it will prevent your app
from receiving updates released with ADT updates and may generate a warning during lint
processing. </p>
<table class="sample"><tr><td align="left" >
<pre>proguard.config=proguard-project.txt</pre>
</td></tr>
</table>
<h2>Modifying proguard-project.txt for the AWS SDK for Android</h2>
<p>
When exporting your app using the AWS SDK for
Android with the default, empty <i>proguard-project.txt</i> file, you may notice that Eclipse
reports errors. In order to correct these errors, add
the following lines to the end of your <i>proguard-project.txt</i> file:
</p>
<table class="sample"><tr><td align="left" >
<pre>-keep class org.apache.commons.logging.** { *; }
-keep class com.amazonaws.services.sqs.QueueUrlHandler { *; }
-keep class com.amazonaws.javax.xml.transform.sax.* { public *; }
-keep class com.amazonaws.javax.xml.stream.** { *; }
-keep class com.amazonaws.services.**.model.*Exception* { *; }
-keep class org.codehaus.** { *; }
-keepattributes Signature,*Annotation*
-dontwarn javax.xml.stream.events.**
-dontwarn org.codehaus.jackson.**
-dontwarn org.apache.commons.logging.impl.**
-dontwarn org.apache.http.conn.scheme.**</pre></td></tr>
</table>
<p>
<b>Note:</b> This configuration applies only to the AWS SDK for
Android; if you are using other third-party libraries, you need to
consult the documentation for those libraries to see if they
require additional configuration to support the use of Proguard.
</p>
<h2>Conclusion and Additional Resources</h2>
<p>
Proguard is a valuable tool for Android developers who care about the
size of their apps. The configuration provided in this
article allows developers to ship apps using the AWS SDK for
Android that use less of the user's storage.
</p>
<p>
All samples in the AWS SDK for Android starting with version 1.3.0
ship with functional Proguard configuration. You can download the
latest version of the AWS SDK for Android <a
href="http://aws.amazon.com/sdkforandroid">here</a>.</p>
<h2>Questions?</h2>
<p>
Please feel free to ask questions or provide comments in the <a
href="https://forums.aws.amazon.com/forum.jspa?forumID=88">Mobile
Development Forum</a>.
</p>
</body>
</html>