From ea4cfcd4b9918c3b20292cb897b689b9f77d0790 Mon Sep 17 00:00:00 2001 From: Inderjeet Singh Date: Fri, 22 Jul 2011 20:55:37 +0000 Subject: [PATCH] initial cut at an example Android application that uses Proguard with Gson --- .../AndroidManifest.xml | 21 +++ .../default.properties | 12 ++ examples/android-proguard-example/pom.xml | 144 ++++++++++++++++++ .../android-proguard-example/proguard.cfg | 69 +++++++++ .../res/drawable/icon.png | Bin 0 -> 2574 bytes .../res/layout/main.xml | 12 ++ .../res/values/strings.xml | 5 + .../android/GsonProguardExampleActivity.java | 36 +++++ 8 files changed, 299 insertions(+) create mode 100755 examples/android-proguard-example/AndroidManifest.xml create mode 100644 examples/android-proguard-example/default.properties create mode 100755 examples/android-proguard-example/pom.xml create mode 100644 examples/android-proguard-example/proguard.cfg create mode 100644 examples/android-proguard-example/res/drawable/icon.png create mode 100644 examples/android-proguard-example/res/layout/main.xml create mode 100644 examples/android-proguard-example/res/values/strings.xml create mode 100644 examples/android-proguard-example/src/com/google/gson/examples/android/GsonProguardExampleActivity.java diff --git a/examples/android-proguard-example/AndroidManifest.xml b/examples/android-proguard-example/AndroidManifest.xml new file mode 100755 index 00000000..7e9b1d8b --- /dev/null +++ b/examples/android-proguard-example/AndroidManifest.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + diff --git a/examples/android-proguard-example/default.properties b/examples/android-proguard-example/default.properties new file mode 100644 index 00000000..7d4fed0b --- /dev/null +++ b/examples/android-proguard-example/default.properties @@ -0,0 +1,12 @@ +# 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 use, +# "build.properties", and override values to adapt the script to your +# project structure. + +# Project target. +target=android-3 +proguard.config=proguard.cfg \ No newline at end of file diff --git a/examples/android-proguard-example/pom.xml b/examples/android-proguard-example/pom.xml new file mode 100755 index 00000000..201cb26a --- /dev/null +++ b/examples/android-proguard-example/pom.xml @@ -0,0 +1,144 @@ + + + + 4.0.0 + com.google.code.gson + android-proguard-example + apk + 1.0-SNAPSHOT + android-proguard-example + http://code.google.com/p/google-gson/trunk/examples/android + An example illustrating using Gson and Progaurd in an Android application + + org.sonatype.oss + oss-parent + 5 + + + UTF-8 + ${env.ANDROID_HOME}/ + + + + + The Apache Software License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + repo + + + + scm:svn:http://google-gson.googlecode.com/svn/trunk/examples/android + scm:svn:https://google-gson.googlecode.com/svn/trunk/examples/android + http://google-gson.codegoogle.com/trunk/examples/android + + + Google Code Issue Tracking + http://code.google.com/p/google-gson/issues/list + + + + com.google.android + android + 1.5_r4 + provided + + + com.google.code.gson + gson + 1.8-SNAPSHOT + provided + + + + + + + com.jayway.maven.plugins.android.generation2 + maven-android-plugin + 2.9.0-beta-4 + + + ${env.ANDROID_HOME}/ + 1.5 + + true + + true + + + org.apache.maven.plugins + maven-compiler-plugin + 2.3.2 + + 1.6 + 1.6 + + + + org.apache.maven.plugins + maven-eclipse-plugin + 2.8 + + true + true + ../../eclipse-ws + + file:///${basedir}/../lib/formatting-styles.xml + + + + + org.apache.maven.plugins + maven-jar-plugin + 2.3.1 + + + + test-jar + + + + + + org.apache.maven.plugins + maven-source-plugin + 2.1.2 + + + attach-sources + + jar + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.7 + + + attach-javadocs + + jar + + + + + + http://download.oracle.com/javase/1.5.0/docs/api/ + + true + public + + + + + + + Inderjeet Singh + + + diff --git a/examples/android-proguard-example/proguard.cfg b/examples/android-proguard-example/proguard.cfg new file mode 100644 index 00000000..b16d8aa4 --- /dev/null +++ b/examples/android-proguard-example/proguard.cfg @@ -0,0 +1,69 @@ +-optimizationpasses 5 +-dontusemixedcaseclassnames +-dontskipnonpubliclibraryclasses +-dontskipnonpubliclibraryclassmembers +-dontpreverify +-verbose +-dump class_files.txt +-printseeds seeds.txt +-printusage unused.txt +-printmapping mapping.txt +-optimizations !code/simplification/arithmetic,!field/*,!class/merging/* + +-allowaccessmodification +-keepattributes *Annotation* +-renamesourcefileattribute SourceFile +-keepattributes SourceFile,LineNumberTable + +-keep public class * extends android.app.Activity +-keep public class * extends android.app.Application +-keep public class * extends android.app.Service +-keep public class * extends android.content.BroadcastReceiver +-keep public class * extends android.content.ContentProvider +-keep public class * extends android.app.backup.BackupAgentHelper +-keep public class * extends android.preference.Preference +-keep public class com.android.vending.licensing.ILicensingService +-dontnote com.android.vending.licensing.ILicensingService + +# Explicitly preserve all serialization members. The Serializable interface +# is only a marker interface, so it wouldn't save them. +-keepclassmembers class * implements java.io.Serializable { + static final long serialVersionUID; + private static final java.io.ObjectStreamField[] serialPersistentFields; + private void writeObject(java.io.ObjectOutputStream); + private void readObject(java.io.ObjectInputStream); + java.lang.Object writeReplace(); + java.lang.Object readResolve(); +} + +# Preserve all native method names and the names of their classes. +-keepclasseswithmembernames class * { + native ; +} + +-keepclasseswithmembernames class * { + public (android.content.Context, android.util.AttributeSet); +} + +-keepclasseswithmembernames class * { + public (android.content.Context, android.util.AttributeSet, int); +} + +# Preserve static fields of inner classes of R classes that might be accessed +# through introspection. +-keepclassmembers class **.R$* { + public static ; +} + +# Preserve the special static methods that are required in all enumeration classes. +-keepclassmembers enum * { + public static **[] values(); + public static ** valueOf(java.lang.String); +} + +-keep class * implements android.os.Parcelable { + public static final android.os.Parcelable$Creator *; +} + +# Gson specific classes +-keep class sun.misc.Unsafe.** { *; } diff --git a/examples/android-proguard-example/res/drawable/icon.png b/examples/android-proguard-example/res/drawable/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..a07c69fa5a0f4da5d5efe96eea12a543154dbab6 GIT binary patch literal 2574 zcmV+p3i0)cP)Q`Og{P|8RRXpj5bgrSmEzSMfBn+{{vpNxw?;5UX;iv9sYxy_`IQHs$i<61a_iv^L>h8s-`D(`e@|IgS*Fj zNGM876Gf;3D8*1UX9a%v>yJKD*QkCwW2AirU(L{qNA)JghmGItc;(H<$!ABY&gBy1vJIEUj-b8%el*o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Ov!z72k3ZnJs{pp| z+pW`DDueC#mEWOf=ucJ!dTL}hzOeiS-i?m2E;`EKz4<&Lu~NnW?peqVU^@<+T3KKu z{yrI%Qy-Z%HEvLUz}n^~m?7x`xuCtNR#L2En!T>dQtIKdS#V-Hzt3RtwTeYtmQ&dR z6qXZvac*oc@BUYEH%@Ylv_1&tSjkbzzU6*h1(3^C`;1z;g_SmOtclS?KWk2VYE zM*oS<=C483XckW?GN|1jfh3Ro(h + + + + + \ No newline at end of file diff --git a/examples/android-proguard-example/res/values/strings.xml b/examples/android-proguard-example/res/values/strings.xml new file mode 100644 index 00000000..ba3be81e --- /dev/null +++ b/examples/android-proguard-example/res/values/strings.xml @@ -0,0 +1,5 @@ + + + Gson Proguard Example + + diff --git a/examples/android-proguard-example/src/com/google/gson/examples/android/GsonProguardExampleActivity.java b/examples/android-proguard-example/src/com/google/gson/examples/android/GsonProguardExampleActivity.java new file mode 100644 index 00000000..eaeb3bed --- /dev/null +++ b/examples/android-proguard-example/src/com/google/gson/examples/android/GsonProguardExampleActivity.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2011 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.gson.examples.android; + +import android.app.Activity; +import android.os.Bundle; +import android.widget.TextView; + +/** + * Activity class illustrating how to use proguard with Gson + * + * @author Inderjeet Singh + */ +public class GsonProguardExampleActivity extends Activity { + @Override + public void onCreate(Bundle icicle) { + super.onCreate(icicle); + setContentView(R.layout.main); + TextView tv = (TextView) findViewById(R.id.tv); + tv.setText("Hello World"); + tv.invalidate(); + } +}