Android 读取properties数据,多渠道打包,apk名字及路径更改等一揽子总结

一、读取properties数据

读取properties配置文件信息有两种方法:

1、写第一种方法的同时将自动化打包方法顺便写了,因为这俩可以共通

将密钥(appstore)相关信息写在程序自建的 gradle.properties 文件内

appstore密钥放置在程序的 app 文件夹下

     变量前必须添加前缀,systemProp.

systemProp.releaseStoreFile = ../app/android.keystore
systemProp.releaseStorePassword = android
systemProp.releaseKeyAlias = android-alias
systemProp.releaseKeyPassword = android

读取配置数据:

    在 app 文件夹内 build.gradle 内 android {} 下加入 signingCofigs {}

    但必须写在 buildTypes {} 前面

signingConfigs {
    appStrore {
        storeFile file(System.properties['releaseStoreFile'])
        storePassword System.properties['releaseStorePassword']
        keyAlias System.properties['releaseKeyAlias']
        keyPassword System.properties['releaseKeyPassword']
    }
}

从上面能看出来读取 gradle.properties 内数据的方式就是,获取到的是字符串:

System.properties['key']

然后再配置 buildType {}

buildTypes {
    release {
        signingConfig signingConfigs.appStrore
    }
    debug {
        signingConfig signingConfigs.appStrore
    }
 }
然后就可以直接动手打包了,打开Android Studio的Terminal根据自己想打的版本填写命令:gradlew assembleRelease或者 gradlew assembleDebug

相应的apk会出现在 app / build / output / apk

当然,release版本和debug版本不一定用同一套appstore,可以分别设置不同的密钥


2、第二种方法, local.properties 文件下或者自己建立一个xxxx .properties 配置文件写键值对都可以

ver
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值