Skip to content

Commit ea4cfcd

Browse files
committed
initial cut at an example Android application that uses Proguard with Gson
1 parent 161b4ba commit ea4cfcd

File tree

8 files changed

+299
-0
lines changed

8 files changed

+299
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.google.gson.examples.android"
4+
android:versionCode="1"
5+
android:versionName="1.0">
6+
<uses-sdk android:minSdkVersion="3"/>
7+
<application android:icon="@drawable/icon" android:label="@string/app_name">
8+
<activity android:name=".GsonProguardExampleActivity"
9+
android:label="@string/app_name"
10+
android:exported="true"
11+
android:icon="@drawable/icon"
12+
android:configChanges="keyboardHidden|orientation"
13+
android:enabled="true">
14+
<intent-filter>
15+
<action android:name="android.intent.action.MAIN" />
16+
<category android:name="android.intent.category.LAUNCHER" />
17+
</intent-filter>
18+
</activity>
19+
</application>
20+
<uses-permission android:name="android.permission.INTERNET" />
21+
</manifest>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# This file is automatically generated by Android Tools.
2+
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3+
#
4+
# This file must be checked in Version Control Systems.
5+
#
6+
# To customize properties used by the Ant build system use,
7+
# "build.properties", and override values to adapt the script to your
8+
# project structure.
9+
10+
# Project target.
11+
target=android-3
12+
proguard.config=proguard.cfg
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<project xmlns="http://maven.apache.org/POM/4.0.0"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
6+
<modelVersion>4.0.0</modelVersion>
7+
<groupId>com.google.code.gson</groupId>
8+
<artifactId>android-proguard-example</artifactId>
9+
<packaging>apk</packaging>
10+
<version>1.0-SNAPSHOT</version>
11+
<name>android-proguard-example</name>
12+
<url>http://code.google.com/p/google-gson/trunk/examples/android</url>
13+
<description>An example illustrating using Gson and Progaurd in an Android application</description>
14+
<parent>
15+
<groupId>org.sonatype.oss</groupId>
16+
<artifactId>oss-parent</artifactId>
17+
<version>5</version>
18+
</parent>
19+
<properties>
20+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
21+
<android.sdk.path>${env.ANDROID_HOME}/</android.sdk.path>
22+
</properties>
23+
24+
<licenses>
25+
<license>
26+
<name>The Apache Software License, Version 2.0</name>
27+
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
28+
<distribution>repo</distribution>
29+
</license>
30+
</licenses>
31+
<scm>
32+
<connection>scm:svn:http://google-gson.googlecode.com/svn/trunk/examples/android</connection>
33+
<developerConnection>scm:svn:https://google-gson.googlecode.com/svn/trunk/examples/android</developerConnection>
34+
<url>http://google-gson.codegoogle.com/trunk/examples/android</url>
35+
</scm>
36+
<issueManagement>
37+
<system>Google Code Issue Tracking</system>
38+
<url>http://code.google.com/p/google-gson/issues/list</url>
39+
</issueManagement>
40+
<dependencies>
41+
<dependency>
42+
<groupId>com.google.android</groupId>
43+
<artifactId>android</artifactId>
44+
<version>1.5_r4</version>
45+
<scope>provided</scope>
46+
</dependency>
47+
<dependency>
48+
<groupId>com.google.code.gson</groupId>
49+
<artifactId>gson</artifactId>
50+
<version>1.8-SNAPSHOT</version>
51+
<scope>provided</scope>
52+
</dependency>
53+
</dependencies>
54+
55+
<build>
56+
<plugins>
57+
<plugin>
58+
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
59+
<artifactId>maven-android-plugin</artifactId>
60+
<version>2.9.0-beta-4</version>
61+
<configuration>
62+
<sdk>
63+
<path>${env.ANDROID_HOME}/</path>
64+
<platform>1.5</platform>
65+
</sdk>
66+
<deleteConflictingFiles>true</deleteConflictingFiles>
67+
</configuration>
68+
<extensions>true</extensions>
69+
</plugin>
70+
<plugin>
71+
<groupId>org.apache.maven.plugins</groupId>
72+
<artifactId>maven-compiler-plugin</artifactId>
73+
<version>2.3.2</version>
74+
<configuration>
75+
<source>1.6</source>
76+
<target>1.6</target>
77+
</configuration>
78+
</plugin>
79+
<plugin>
80+
<groupId>org.apache.maven.plugins</groupId>
81+
<artifactId>maven-eclipse-plugin</artifactId>
82+
<version>2.8</version>
83+
<configuration>
84+
<downloadSources>true</downloadSources>
85+
<downloadJavadocs>true</downloadJavadocs>
86+
<workspace>../../eclipse-ws</workspace>
87+
<workspaceCodeStylesURL>
88+
file:///${basedir}/../lib/formatting-styles.xml
89+
</workspaceCodeStylesURL>
90+
</configuration>
91+
</plugin>
92+
<plugin>
93+
<groupId>org.apache.maven.plugins</groupId>
94+
<artifactId>maven-jar-plugin</artifactId>
95+
<version>2.3.1</version>
96+
<executions>
97+
<execution>
98+
<goals>
99+
<goal>test-jar</goal>
100+
</goals>
101+
</execution>
102+
</executions>
103+
</plugin>
104+
<plugin>
105+
<groupId>org.apache.maven.plugins</groupId>
106+
<artifactId>maven-source-plugin</artifactId>
107+
<version>2.1.2</version>
108+
<executions>
109+
<execution>
110+
<id>attach-sources</id>
111+
<goals>
112+
<goal>jar</goal>
113+
</goals>
114+
</execution>
115+
</executions>
116+
</plugin>
117+
<plugin>
118+
<groupId>org.apache.maven.plugins</groupId>
119+
<artifactId>maven-javadoc-plugin</artifactId>
120+
<version>2.7</version>
121+
<executions>
122+
<execution>
123+
<id>attach-javadocs</id>
124+
<goals>
125+
<goal>jar</goal>
126+
</goals>
127+
</execution>
128+
</executions>
129+
<configuration>
130+
<links>
131+
<link>http://download.oracle.com/javase/1.5.0/docs/api/</link>
132+
</links>
133+
<version>true</version>
134+
<show>public</show>
135+
</configuration>
136+
</plugin>
137+
</plugins>
138+
</build>
139+
<developers>
140+
<developer>
141+
<name>Inderjeet Singh</name>
142+
</developer>
143+
</developers>
144+
</project>
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
-optimizationpasses 5
2+
-dontusemixedcaseclassnames
3+
-dontskipnonpubliclibraryclasses
4+
-dontskipnonpubliclibraryclassmembers
5+
-dontpreverify
6+
-verbose
7+
-dump class_files.txt
8+
-printseeds seeds.txt
9+
-printusage unused.txt
10+
-printmapping mapping.txt
11+
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
12+
13+
-allowaccessmodification
14+
-keepattributes *Annotation*
15+
-renamesourcefileattribute SourceFile
16+
-keepattributes SourceFile,LineNumberTable
17+
18+
-keep public class * extends android.app.Activity
19+
-keep public class * extends android.app.Application
20+
-keep public class * extends android.app.Service
21+
-keep public class * extends android.content.BroadcastReceiver
22+
-keep public class * extends android.content.ContentProvider
23+
-keep public class * extends android.app.backup.BackupAgentHelper
24+
-keep public class * extends android.preference.Preference
25+
-keep public class com.android.vending.licensing.ILicensingService
26+
-dontnote com.android.vending.licensing.ILicensingService
27+
28+
# Explicitly preserve all serialization members. The Serializable interface
29+
# is only a marker interface, so it wouldn't save them.
30+
-keepclassmembers class * implements java.io.Serializable {
31+
static final long serialVersionUID;
32+
private static final java.io.ObjectStreamField[] serialPersistentFields;
33+
private void writeObject(java.io.ObjectOutputStream);
34+
private void readObject(java.io.ObjectInputStream);
35+
java.lang.Object writeReplace();
36+
java.lang.Object readResolve();
37+
}
38+
39+
# Preserve all native method names and the names of their classes.
40+
-keepclasseswithmembernames class * {
41+
native <methods>;
42+
}
43+
44+
-keepclasseswithmembernames class * {
45+
public <init>(android.content.Context, android.util.AttributeSet);
46+
}
47+
48+
-keepclasseswithmembernames class * {
49+
public <init>(android.content.Context, android.util.AttributeSet, int);
50+
}
51+
52+
# Preserve static fields of inner classes of R classes that might be accessed
53+
# through introspection.
54+
-keepclassmembers class **.R$* {
55+
public static <fields>;
56+
}
57+
58+
# Preserve the special static methods that are required in all enumeration classes.
59+
-keepclassmembers enum * {
60+
public static **[] values();
61+
public static ** valueOf(java.lang.String);
62+
}
63+
64+
-keep class * implements android.os.Parcelable {
65+
public static final android.os.Parcelable$Creator *;
66+
}
67+
68+
# Gson specific classes
69+
-keep class sun.misc.Unsafe.** { *; }
2.51 KB
Loading
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
3+
<LinearLayout
4+
xmlns:android="http://schemas.android.com/apk/res/android"
5+
android:orientation="vertical"
6+
android:layout_width="fill_parent"
7+
android:layout_height="fill_parent">
8+
9+
<TextView android:id="@+id/tv"
10+
android:layout_width="fill_parent"
11+
android:layout_height="wrap_content" />
12+
</LinearLayout>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<string name="app_name">Gson Proguard Example</string>
4+
</resources>
5+
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright (C) 2011 Google Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.google.gson.examples.android;
17+
18+
import android.app.Activity;
19+
import android.os.Bundle;
20+
import android.widget.TextView;
21+
22+
/**
23+
* Activity class illustrating how to use proguard with Gson
24+
*
25+
* @author Inderjeet Singh
26+
*/
27+
public class GsonProguardExampleActivity extends Activity {
28+
@Override
29+
public void onCreate(Bundle icicle) {
30+
super.onCreate(icicle);
31+
setContentView(R.layout.main);
32+
TextView tv = (TextView) findViewById(R.id.tv);
33+
tv.setText("Hello World");
34+
tv.invalidate();
35+
}
36+
}

0 commit comments

Comments
 (0)