Android的工作室 - 如何ZipAlign APK [英] Android Studio - How to ZipAlign apk

查看:158
本文介绍了Android的工作室 - 如何ZipAlign APK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经采用Android Studio创建一个签名的apk,我现在要zipalign它,我已阅读本: <一href="http://developer.android.com/tools/help/zipalign.html">http://developer.android.com/tools/help/zipalign.html 但我仍然不知道在哪里加code线,是它在摇篮文件,并在文件中,我加入了线?

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?

推荐答案

在里面你主要模块的 build.gradle 文件,你可以有多个版本的类型以及调试之一。

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

您可以像

buildTypes {

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

注意:旧版本使用 zipAlign ,而不是 zipAlignEnabled

Note: Older versions use zipAlign, instead of zipAlignEnabled

默认摇篮任务总是调试创建,您是否定义或没有释放buildTypes。调试是为了调试和发布烧焦的应用程序的(生成>生成签名的.apk)。您必须确定您的signingConfig的发布版本。

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

检查生成类型一节中提到下面的链接,你可以在你的buildTypes使用其他的属性。

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

<一个href="http://tools.android.com/tech-docs/new-build-system/user-guide">http://tools.android.com/tech-docs/new-build-system/user-guide

这篇关于Android的工作室 - 如何ZipAlign APK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆