Android打包签名信息配置

0x00 debug.keystore路径

C:\Users\xxx.android\debug.keystore

0x01 创建签名配置文件

这个文件不要传到仓库中!!!

工程根目录下sign.properties

文件内容(替换为自己的签名文件)

STORE_FILE=d:/xxx/debug.keystore
STORE_PASSWORD=android
KEY_ALIAS=AndroidDebugKey
KEY_PASSWORD=android

0x02 修改模块的签名配置

App module中的builg.gradle中,读取配置文件中的签名信息

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "com.iamcxl.myapplication"
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 2
        versionName "1.1"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

    signingConfigs {
        release {
            File propFile = file('../sign.properties');
            if (propFile.exists()) {
                def Properties props = new Properties()
                props.load(new FileInputStream(propFile))
                if (props.containsKey('STORE_FILE') && props.containsKey('STORE_PASSWORD') &&
                        props.containsKey('KEY_ALIAS') && props.containsKey('KEY_PASSWORD')) {
                    println 'signingConfigs:release: read sign.properties attribute ok!'
                    storeFile = file(props['STORE_FILE'])
                    storePassword = props['STORE_PASSWORD']
                    keyAlias = props['KEY_ALIAS']
                    keyPassword = props['KEY_PASSWORD']
                } else {
                    println 'signingConfigs:release: read sign.properties attribute fail!'
                    storeFile file("d:/xxx/debug.keystore")
                    storePassword "android"
                    keyAlias "AndroidDebugKey"
                    keyPassword "android"
                }
            } else {
                println 'signingConfigs:release: sign.properties not found!'
                storeFile file("d:/xxx/debug.keystore")
                storePassword "android"
                keyAlias "AndroidDebugKey"
                keyPassword "android"
            }

        }
        debug {
            File propFile = file('../sign.properties');
            if (propFile.exists()) {
                def Properties props = new Properties()
                props.load(new FileInputStream(propFile))
                if (props.containsKey('STORE_FILE') && props.containsKey('STORE_PASSWORD') &&
                        props.containsKey('KEY_ALIAS') && props.containsKey('KEY_PASSWORD')) {
                    storeFile = file(props['STORE_FILE'])
                    storePassword = props['STORE_PASSWORD']
                    keyAlias = props['KEY_ALIAS']
                    keyPassword = props['KEY_PASSWORD']

                    println 'signingConfigs:debug: read sign.properties attribute ok!'
                } else {
                    storeFile file("d:/xxx/debug.keystore")
                    storePassword "android"
                    keyAlias "AndroidDebugKey"
                    keyPassword "android"
                    println 'signingConfigs:debug: read sign.properties attribute fail!'
                }
            } else {
                println 'signingConfigs:debug: sign.properties not found!'
                storeFile file("d:/xxx/debug.keystore")
                storePassword "android"
                keyAlias "AndroidDebugKey"
                keyPassword "android"
            }
        }
    }

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

        debug {
            debuggable true
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.release
        }

    }


}

0x03 安装

adb install -r android-debug.apk
or 
adb install -r android-release.apk 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值