Search Unity

Use "Split APKs by target architecture" with custom version code

Discussion in 'Android' started by thibouf, May 21, 2019.

  1. thibouf

    thibouf

    Joined:
    Mar 17, 2017
    Posts:
    105
    Hello,

    I would like to use the feature Split APKs by target architecture to generate smaller apk .But as the doc say :

    My problem is my app already have a version code > 100000 and is live so I cannot reduce it. Is there anyway to override the way each architecture apk version code is generated during the build process ?
     
  2. Flarup

    Flarup

    Joined:
    Jan 7, 2010
    Posts:
    164
    I'm a bit puzzled by this as well. Couldn't you use bundleVersionCode + 1 and bundleVersionCode + 2 when splitting apk by target architecture?

    Also, when I uploaded the 64 bit build I got a warning saying that the bundleVersionCode was only set for 32 bit build, not for 64 bit build (using Unity 2018.4.0f1).
     
  3. MetaDOS

    MetaDOS

    Joined:
    Nov 10, 2013
    Posts:
    157
    Just tick to ARM64 to generate 64bit apk.
     
  4. trooper

    trooper

    Joined:
    Aug 21, 2009
    Posts:
    748
  5. trooper

    trooper

    Joined:
    Aug 21, 2009
    Posts:
    748
    @thibouf

    This works if you are using Gradle build system (without exporting obviously)

    upload_2019-9-23_22-39-16.png

    Code (CSharp):
    1.  
    2. using System.IO;
    3. using UnityEditor.Android;
    4. using UnityEditor.Build;
    5.  
    6. class GradlePostProcess : IPostGenerateGradleAndroidProject
    7. {
    8.     int IOrderedCallback.callbackOrder => 0;
    9.  
    10.     void IPostGenerateGradleAndroidProject.OnPostGenerateGradleAndroidProject(string path)
    11.     {
    12.  
    13.         var buildGradlePath = Path.Combine(path, "build.gradle");
    14.  
    15.         var buildGradle = File.ReadAllText(buildGradlePath);
    16.      
    17.         buildGradle = buildGradle.Replace("baseAbiVersionCode * 100000 + variant.versionCode", "baseAbiVersionCode * 1000000 + variant.versionCode");
    18.  
    19.         File.WriteAllText(buildGradlePath, buildGradle);
    20.     }
    21.  
    22. }
    23.  
     
    Petr777 likes this.
  6. Rachan

    Rachan

    Joined:
    Dec 3, 2012
    Posts:
    781
    my bunddle number is 300354!

    actually I don't want it like this
    But my team made said it will be a date pattern
    like day 30 month 3 and year 2554
    so 300354!

    But this is nonesense and not ok for me...