Android 构建自动化打包;获取MD5、SHA1、SHA-256

Android 构建自动化打包;获取MD5、SHA1、SHA-256

  • 构建自动化打包
    • 编辑脚本文件
    • 获取正式版和测试版apk
    • 获取正式版和测试版的 MD5、SHA1、SHA-256

构建自动化打包

首先提示下:
Gradle是一个基于JVM的构建工具,是一款通用灵活的构建工具,支持maven, Ivy仓库,支持传递性 依赖管理,而不需要远程仓库或者是pom.xml和ivy.xml配置文件,基于Groovy,build脚本使用Groovy编写。说到底,它终究是一个脚本,熟悉脚本的朋友就很清楚,脚本的语言特性,不清楚的也没事,知道Android Studio中gradle是脚本编写下配置就行

编辑脚本文件

1.首先在app module中build.gradle文件中 配置signingConfigs 闭包

signingConfigs {
        release {
            storeFile file('D:\\AndroidProjects\\aaa\\bbb\\app\\my.jks')
            storePassword '123456'
            keyAlias 'alias'
            keyPassword '123456'
        }
        debug {
             storeFile file('D:\\AndroidProjects\\aaa\\bbb\\app\\my.jks')
            torePassword '123456'
            keyAlias 'alias'
            keyPassword '123456'
        }
      }

2.同样在上面文件中继续

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.release//签名文件配置 
        }
        debug {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.debug//签名文件配置
        }
    }

3.点击“Sync Now” ,接下来就可以通过点点点的方式来build 正式版、测试版的apk文件了,当然也可以获取正式版和测试版的 MD5、SHA1、SHA-256 了

获取正式版和测试版apk

Android 构建自动化打包;获取MD5、SHA1、SHA-256_第1张图片
1.Gradle-> 项目 ->Tasks->build ->assembleDebug 编译测试版apk文件
2.Gradle-> 项目 ->Tasks->build ->assembleRelease 编译正式版apk文件
3.Gradle-> 项目 ->Tasks->build ->assemble 同时编译正式版和测试版apk文件

获取正式版和测试版的 MD5、SHA1、SHA-256

Gradle-> 项目 ->Tasks->android->signingReport

> Task :app:signingReport
Variant: debugUnitTest
Config: config
Store: D:\AndroidProjects\xx\xx\app\my.jks
Alias: alias
MD5: C6:B8:2E:D4:57:07:03:C4:E5:3F:CE:64:B7:2E:B3:C1
SHA1: 29:1F:08:27:A5:9D:2B:86:CB:FE:1A:2C:6A:B3:3F:FB:E8:01:E9:F7
SHA-256: 4D:AB:6D:08:23:15:20:1D:03:ED:B0:EF:60:97:DD:88:9D:12:6B:17:FA:16:35:A6:CC:49:D0:64:A6:EF:EA:D1
Valid until: 2045��6��2�� ������
----------
Variant: releaseUnitTest
Config: config
Store: D:\AndroidProjects\xx\xx\app\my.jks
Alias: alias
MD5: C6:B8:2E:D4:57:07:03:C4:E5:3F:CE:64:B7:2E:B3:C1
SHA1: 29:1F:08:27:A5:9D:2B:86:CB:FE:1A:2C:6A:B3:3F:FB:E8:01:E9:F7
SHA-256: 4D:AB:6D:08:23:15:20:1D:03:ED:B0:EF:60:97:DD:88:9D:12:6B:17:FA:16:35:A6:CC:49:D0:64:A6:EF:EA:D1
Valid until: 2045��6��2�� ������
----------
Variant: release
Config: config
Store: D:\AndroidProjects\xx\xx\app\my.jks
Alias: alias
MD5: C6:B8:2E:D4:57:07:03:C4:E5:3F:CE:64:B7:2E:B3:C1
SHA1: 29:1F:08:27:A5:9D:2B:86:CB:FE:1A:2C:6A:B3:3F:FB:E8:01:E9:F7
SHA-256: 4D:AB:6D:08:23:15:20:1D:03:ED:B0:EF:60:97:DD:88:9D:12:6B:17:FA:16:35:A6:CC:49:D0:64:A6:EF:EA:D1
Valid until: 2045��6��2�� ������
----------
Variant: debugAndroidTest
Config: config
Store: D:\AndroidProjects\xx\xx\app\my.jks
Alias: alias
MD5: C6:B8:2E:D4:57:07:03:C4:E5:3F:CE:64:B7:2E:B3:C1
SHA1: 29:1F:08:27:A5:9D:2B:86:CB:FE:1A:2C:6A:B3:3F:FB:E8:01:E9:F7
SHA-256: 4D:AB:6D:08:23:15:20:1D:03:ED:B0:EF:60:97:DD:88:9D:12:6B:17:FA:16:35:A6:CC:49:D0:64:A6:EF:EA:D1
Valid until: 2045��6��2�� ������
----------
Variant: debug
Config: config
Store: D:\AndroidProjects\xx\xx\app\my.jks
Alias: alias
MD5: C6:B8:2E:D4:57:07:03:C4:E5:3F:CE:64:B7:2E:B3:C1
SHA1: 29:1F:08:27:A5:9D:2B:86:CB:FE:1A:2C:6A:B3:3F:FB:E8:01:E9:F7
SHA-256: 4D:AB:6D:08:23:15:20:1D:03:ED:B0:EF:60:97:DD:88:9D:12:6B:17:FA:16:35:A6:CC:49:D0:64:A6:EF:EA:D1
Valid until: 2045��6��2�� ������
----------

我这里debug和release ,jks同一个,所以正式版和测试版的值一样,通常自己可以配置不同版本,
拿到的就是不一样的

你可能感兴趣的:(Android,移动应用)