Android Studio - 如何 ZipAlign apk [英] Android Studio - How to ZipAlign apk

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

问题描述

我已经使用 Android Studio 创建了一个签名的 apk,现在我要对其进行 zipalign,我已经阅读了以下内容:http://developer.android.com/tools/help/zipalign.html但我仍然不确定在哪里添加代码行,是在 Gradle 文件中吗?我应该在文件中的哪个位置添加代码行?

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

无论您是否定义,始终为调试和发布构建类型创建默认的 gradle 任务.调试用于调试目的和签名应用程序发布(构建 >> 生成签名 Apk).您必须为发布版本定义签名配置.

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-文档/新构建系统/用户指南

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

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