android 每日构建_Android构建类型和产品风味

android 每日构建

In this tutorial, we’ll be discussing Android Build Types and Product Flavors. We’ll see how they make our Android Development easier and faster especially when we’re creating applications with minimal differences. These differences can be as small as changes in themes and app icons or can be for different stages of the product such as dev, beta, production etc.

在本教程中,我们将讨论Android构建类型和产品风味。 我们将了解它们如何使我们的Android开发更加轻松快捷,尤其是在创建差异最小的应用程序时。 这些差异可以与主题和应用程序图标的变化一样小,也可以针对产品的不同阶段(例如开发,测试版,生产等)进行。

Create a new project in your Android Studio and choose the Basic activity. In the next section, we’ll look at build types.

在Android Studio中创建一个新项目,然后选择基本活动。 在下一节中,我们将介绍构建类型。

Android构建类型 (Android Build Types)

Once the new project is created, by default it consists of two build types/variants – debug, release.

创建新项目后,默认情况下,它由两种构建类型/变量组成:调试,发布。

Debug is the build type that is used when we run the application from the IDE directly onto a device.

调试是当我们从IDE直接在设备上运行应用程序时使用的构建类型。

A release is the build type that requires you to sign the APK. The release builds are meant to be uploaded to the play store. In the release build type, we obfuscate the code using ProGuard to prevent reverse engineering.

发布是一种构建类型,要求您对APK进行签名。 该发行版本应上传到Play商店。 在发行版本类型中,我们使用ProGuard混淆代码以防止进行逆向工程。

Following image shows the default build types.

android build types variants

下图显示了默认的构建类型。

In the build.gradle by default, only the release build type block is written:

默认情况下,在build.gradle ,仅写入release构建类型块:

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

We can add properties on the other build types too.
Before we do that let’s add some signingConfigs to the android block.

我们也可以在其他构建类型上添加属性。
在此之前,让我们向android块添加一些signingConfigs

signingConfigs {
        release {
            storeFile file("release-key.keystore")
            storePassword 'password'
            keyAlias 'alias'
            keyPassword 'journaldev'
        }
    }
Make sure you’ve created a signed key file with the release-key name and the above password from Build | Generate Signed APK for the above code to work.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值