[Android] Fix versioncode with AGP 3.0

Geoffrey Métais git at videolan.org
Mon Jan 29 09:49:22 CET 2018


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Jan 29 09:46:54 2018 +0100| [305506db941106f124ba94afd745dad0e66a393f] | committer: Geoffrey Métais

Fix versioncode with AGP 3.0

> https://code.videolan.org/videolan/vlc-android/commit/305506db941106f124ba94afd745dad0e66a393f
---

 vlc-android/build.gradle | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/vlc-android/build.gradle b/vlc-android/build.gradle
index d5035822b..b3a078eab 100644
--- a/vlc-android/build.gradle
+++ b/vlc-android/build.gradle
@@ -154,8 +154,6 @@ android {
 
     // make per-variant version code
     applicationVariants.all { variant ->
-        // set the composite code
-        variant.mergedFlavor.versionCode = variant.productFlavors.get(0).versionCode * 10000000 + defaultConfig.versionCode + variant.productFlavors.get(1).versionCode
 
         //Custom APK name
         variant.outputs.all { output ->
@@ -164,6 +162,15 @@ android {
                 outputName += variant.productFlavors.get(0).name.toUpperCase() + "-"
             outputName += variant.versionName + "-" + variant.productFlavors.get(1).name + ".apk"
             outputFileName = outputName
+            output.processManifest.doLast {
+                // set the composite code
+                def generatedCode = variant.productFlavors.get(0).versionCode * 10000000 + defaultConfig.versionCode + variant.productFlavors.get(1).versionCode
+                String manifestPath = "$manifestOutputDirectory/AndroidManifest.xml"
+                def manifestContent = file(manifestPath).getText()
+                manifestContent = manifestContent.replace('android:versionCode="1"',
+                        String.format('android:versionCode="%s"', generatedCode))
+                file(manifestPath).write(manifestContent)
+            }
         }
     }
 



More information about the Android mailing list