Android:如何从文件名.apk(app-release_v3.apk)中的build.gradle传输代码版本号

时间:2016-04-13 07:26:22

标签: android android-gradle build.gradle

我需要从文件名.apk中的build.gradle传输代码版本号。例如,app-release_v3.apk。

请帮助找到解决方案。谢谢!

2 个答案:

答案 0 :(得分:0)

在app模块的build.gradle中

android {
   ...

   defaultConfig {
      ...

      archivesBaseName = "MyAppName_v${versionName}"
   }
}  

结果您将拥有MyAppName_v3-release.apk

答案 1 :(得分:0)

您可以使用Dim pstcodee As Integer pstcodee = InStr(1, b4, "Postcode: ") Dim enqui As Integer enqui = InStr(1, b4, "Enquiry:") Dim pstenquire As String pstenquire = Mid(b4, pstcodee, enqui - pstcodee) Dim bup2222() As String bup2222 = Split(pstenquire, ":") postcode = bup2222(1) 文件中的"archivesBaseName"媒体资源。

Somenthing like:

build.gradle