With ant packaging, it's a bit of a hassle if the script is written step-by-step.
For Ant, let's look at it in detail:
Ant supports commands such as Ant debug,ant release, we need the signature to be confused, then we need ant release this command.
First of all: Ant environment, I will not say more, many blogs have introduced, including some environmental configuration
Then: After the ant environment is OK, we need a build.xml file, which is what ant compiles to find.
<?xml version="1.0" encoding="UTF-8"?>
<project
name="EPAPP"
default="helpme" >
<property file="local.properties" />
<property file="ant.properties" />
<loadproperties srcFile="project.properties" />
<!-- quick check on sdk.dir -->
<fail
message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through an env var"
unless="sdk.dir" />
<import
file="custom_rules.xml"
optional="true" />
<!-- import file="build_of_sdk.xml" / -->
<import file="${sdk.dir}/tools/ant/build.xml" />
<target
name="cleand"
depends="clean" >
<delete file="./assets/config.properties"/>
</target>
<target
name="d"
depends="cleand" >
<property
name="out.final.file"
value="./dist/develop/ep.apk" />
<mkdir dir="./dist/develop"/>
<antcall target="release" />
</target>
<target name="helpme">
<echo>Android Ant Build For EPAPP. Available targets:</echo>
<echo> helpme: Displays this help.</echo>
<echo> d: Builds for final.</echo>
<echo> Final release for production.</echo>
<echo>Please feel free to ask help from wangle@easipass.com</echo>
<echo>Sorry for this messed English show. :) </echo>
</target>
</project>
This script corresponds to Ant's Build.xml is not a little bit, but pay attention to configure environment variables OH.
Where the <import file= "${sdk.dir}/tools/ant/build.xml"/> is the one that was imported into Ant's own build.xml, because the script was imported
<antcall target= "release"/> This sentence can be performed normally
And then: We add an ant-used configuration script: This script is executed by Ant Build.xml, and we don't care.
File name is Ant.properties
Proguard.config=proguard.cfg
key.store=./xxxxx.keystore
key.alias=xxxx
key.store.password=123456
key.alias.password=123456
Needless to say, you know what it is. Oh, open the confusion, import the signature. The first line is to open the confusion, the second line is the import signature, and the signature password
As for the signature, I will not say, with a signature
Key.store=./xxxxx.keystore this is to give the signature of the path, I was directly copy the signature to the engineering directory, you can configure your own OH.
Here, the shelves have been built. Oh, the next is according to their special needs, add some processing
Here's a little bit of a control to introduce confusion
Proguard.cfg This is a confusing script, because some of the three-party package and Android came with four components, and so on, we can not confuse them (the three-party package has been confused once, confusion will be problematic, and the four formed because they will be called by the Android system, confusion, the system can not find), otherwise there will be problems
The confusion about JSON should be noted in particular, referring to the previous blog http://blog.csdn.net/brightshadow11111/article/details/9469159
I posted my proguard.cfg script.
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-dontoptimize
-ignorewarnings
-optimizations! code / simplification / arithmetic,! field / * ,! class / merging / *
-keepattributes Signature
#Here are some tripartite packages used in the import project
-libraryjars libs / android-support-v4.jar
-libraryjars libs / umeng_sdk.jar
-libraryjars libs / android-wheel.jar
-libraryjars libs / com.springsource.org.apache.commons.beanutils-1.8.0.jar
-libraryjars libs / com.springsource.org.apache.commons.collections-3.2.1.jar
-libraryjars libs / com.springsource.org.apache.commons.lang-2.1.0.jar
-libraryjars libs / com.springsource.org.apache.commons.net-1.4.1.jar
-libraryjars libs / core.jar
-libraryjars libs / ezmorph-1.0.1.jar
-libraryjars libs / gson-1.7.1.jar
-libraryjars libs / json-lib-2.3-jdk15.jar
-libraryjars libs / ksoap2-android-assembly-3.0.0-RC.4-jar-with-dependencies.jar
-libraryjars libs / locSDK_3.1.jar
-libraryjars libs / mobiletools.jar
-libraryjars libs / pinyin4j-1.1.0.jar
-dontskipnonpubliclibraryclassmembers
-dontskipnonpubliclibraryclasses
#Here is the treatment of gson
-keep class com.google. ** {*;}
-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 ();
}
## --------------- Begin: proguard configuration for Gson ----------
# Gson uses generic type information stored in a class file when working with fields. Proguard
# removes such information by default, so configure it to keep all of it.
-keepattributes Signature
# Gson specific classes
-keep class sun.misc.Unsafe {*;}
# -keep class com.google.gson.stream. ** {*;}
# Application classes that will be serialized / deserialized over Gson
<span style = "margin: 0px; padding: 0px; color: rgb (255, 0, 0);">-keep class com. <span style = "margin: 0px; padding: 0px; font-family: Arial, Helvetica, sans-serif; "> xxxx </ span> <span style =" margin: 0px; padding: 0px; font-family: Arial, Helvetica, sans-serif; ">. Cmb.entity. ** {*; } </ span> </ span>
#Here is the javabean processing for gson
-keep class com. <span style = "margin: 0px; padding: 0px; font-family: Arial, Helvetica, sans-serif;"> xxxx </ span> <span style = "margin: 0px; padding: 0px; font-family: Arial, Helvetica, sans-serif; ">. ct.entity. ** {*;} </ span> <br style="margin: 0px; padding: 0px;" />
-keep class com.xxxx.entity. ** {*;} -keep class com.xxxxx.entity. ** {*;} ## --------------- End: proguard configuration for Gson ----------- 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-keep public class * extends net.sf.json.xml.XMLSerializer-keep class android.support.v4. ** {*;} -keep interface android.support.v4. app. ** {*;} -keep public class * extends android.support.v4. ** -keep
public class * extends android.app.Fragment-keep class com.google.gson.stream. ** {*;} -keep class com.google.gson.examples.android.model. ** {*;} -keepclasseswithmembernames class * {native <methods>;}-keepclasseswithmembers class * {public <init> (android.content.Context,
android.util.AttributeSet);}-keepclasseswithmembers class * {public <init> (android.content.Context, android.util.AttributeSet, int);}-keepclassmembers class * extends android.app.Activity {public void * (android .view.View);}-keepclassmembers enum * {public
static ** [] values (); public static ** valueOf (java.lang.String);}-keep class * implements android.os.Parcelable {public static final android.os.Parcelable $ Creator *;}-keep public class com.easipass.common.net.secret
#Here is not to confuse the tripartite package
-keep class com.motorola. ** {*;}-keep class com.baidu.location. ** {*;}-keep class com.google.zxing. ** {*;}-keep class android.support. v4. ** {*;}-keep class net.sourceforge.pinyin4j. ** {*;}-keep class kankan.wheel.widget. ** {*;}-keep class org.apache.commons.collections. * * {*;}-keep class org.apache.commons.beanutils. ** {*;}-keep class org.apache.commons.lang. ** {*;}-keep class org.apache.commons.net. ** {*;}-keep class net.sf.ezmorph. ** {*;}-keep class net.sf.json. ** {*;}-keep class com.easipass.util.tools. ** { *;}-keep class com.umeng.analytics. ** {*;}-keep class com.umeng.common. ** {*;}-keep class com.easipass.common.net. ** {*;} -keep class net.sf. ** {*;}-keep class com.badlogic. ** {*;}-keep class * implements com.badlogic.gdx.utils.Json *