Android Studio 打包Apk文件,更改默认打包apk文件名称

(1)Android Studio菜单Build->Generate Signed APK 


(2)弹出窗口 


(3)创建密钥库及密钥,创建后会自动选择刚创建的密钥库和密钥(已拥有密钥库跳过) 
    点击“Create new...”按钮创建密钥库 


      Key store path:密钥库文件的地址 
        Password/Confirm:密钥库的密码 
        Key: 
            Alias:密钥名称 
            Password/Confirm:密钥密码 
            Validity(years):密钥有效时间 
            First and Last Name:密钥颁发者姓名 
            Organizational Unit:密钥颁发组织 
            City or Locality:城市 
            Country Code(XX):国家 
(4)选择已存在密钥库及密钥(在(3)中创建密钥库后跳过此步骤) 
    点击“Choose existing...”按钮找到密钥库文件 
    Key store password输入已选择的密钥库文件的密码 
    点击Key alias后的“...”按钮,选择或者创建一个密钥 


(5)点击“Next”按钮,选择保存路径后,点击“Finish”按钮完成 



【修改打包后的默认apk名称】


需在build.gradle(app)中的android中增加

  
  
  1. applicationVariants.all {
  2. variant ->
  3. variant.outputs.each {
  4. output ->
  5. def outputFile = output.outputFile
  6. def fileName
  7. if (outputFile != null && outputFile.name.endsWith('.apk')) {
  8. if (variant.buildType.name.equals('release')) {
  9. fileName = "名称${defaultConfig.versionName}_${defaultConfig.versionCode}.apk"
  10. } else if (variant.buildType.name.equals('debug')) {
  11. fileName = "名称${defaultConfig.versionName}_${defaultConfig.versionCode}_debug.apk"
  12. }
  13. output.outputFile = new File(outputFile.parent, fileName)
  14. }
  15. }
  16. }




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值