Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
179 views
in Technique[技术] by (71.8m points)

Android Studio - How to ZipAlign apk

I have created a signed apk using Android Studio and I'm now going to zipalign it, I have read this: http://developer.android.com/tools/help/zipalign.html but I'm still not sure where to add the lines of code, is it in the Gradle file and where in the file do I add the lines?

question from:https://stackoverflow.com/questions/21242678/android-studio-how-to-zipalign-apk

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Inside you main module's build.gradle file you can have multiple build types along with your debug one.

You can specify zipAlign characteristic inside any of your buildType by using

buildTypes {

     release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        zipAlignEnabled true
    }
}

Note: Older versions use zipAlign, instead of zipAlignEnabled

Default gradle tasks always created for debug and release buildTypes whether you define or not. Debug is for debugging purpose and Release for Signed Application (Build >> Generate Signed Apk). You must define your signingConfig for release builds.

Check Build Types section in below mentioned link for other properties that you can use in your buildTypes

http://tools.android.com/tech-docs/new-build-system/user-guide


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...