1、在项目app下的build.gradle中的android标签中做如下配置:


android.applicationVariants.all { variant ->
variant.outputs.each { output ->
def outputFile = output.outputFile 
if (outputFile != null && outputFile.name.endsWith('.apk')) { 
// 这里修改apk名称 
def fileName = outputFile.name.replace("app", "xxoo_${defaultConfig.versionName}.${defaultConfig.versionCode}_${releaseTime()}") 
output.outputFile = new File(outputFile.parent, fileName) 
}
}
}

2、在项目app下的build.gradle中的android标签中做如下配置,如果碰到以下错误:


Cannot set the value of read-only property 'outputFile’….

参考文章: Android Gradle 3.0.0-alpha2 plugin, Cannot set the value of read-only property 'outputFile'

请尝试下边的操作方式:
android.applicationVariants.all { variant ->
variant.outputs.all { output ->
def outputFile = output.outputFile 
if (outputFile != null && outputFile.name.endsWith('.apk')) { 
// 这里修改apk名称 
def fileName = outputFile.name.replace("app", "xxoo_${defaultConfig.versionName}.${defaultConfig.versionCode}_${releaseTime()}") 
outputFileName = new File(outputFile.parent, fileName) 
}
}
}

更多相关文章

  1. Windows下,Android Studio项目路径中包含中文字符无法编译的问题
  2. android studio 3.0配置自定义打包名称
  3. Google code android开源项目(二)
  4. android项目中的功能清单文件
  5. android 开源项目介绍
  6. Android输入框格式化Edittexthelp(有项目可下载)
  7. android 命令获取手机中项目数据库
  8. android项目,从服务器端返回JSON数据,在android客户端进行显示。
  9. Android利用资源名称获取其id之getIdentifier()方法

随机推荐

  1. [Gradle for Android(安卓)笔记系列]二
  2. 将Android项目导入到Eclipse开发环境
  3. Android修改system只读权限:remount
  4. Android帧缓冲区(Frame Buffer)硬件抽象层(H
  5. Android应用程序四大组件
  6. android 控制屏幕亮度
  7. android实现自定义相机以及图片的水印
  8. Android中UI设计的一些技巧!!!
  9. Android通过OpenSL ES播放音频套路详解
  10. 【实习周记】Android(安卓)getevent.c源