Gradle: applicationVariants.all skips one variant

后端 未结 3 1919
感情败类
感情败类 2021-02-03 13:00

I\'m using Gradle to compile my Android project:

buildTypes {
    release {
        signingConfig signingConfigs.release 
        applicationVariants.all { varia         


        
3条回答
  •  悲&欢浪女
    2021-02-03 13:38

    I solved using this code:

    buildTypes {
        release {
            signingConfig signingConfigs.release 
        }
    
        applicationVariants.all { variant ->
            def apk = variant.packageApplication.outputFile;
            def newName = apk.name.replace(".apk", "-renamed.apk");
            variant.packageApplication.outputFile = new File(apk.parentFile, newName);
            if (variant.zipAlign) {
                variant.zipAlign.outputFile = new File(apk.parentFile, newName.replace("-unaligned", ""));
            }
        }
    }
    

    The block applicationVariants.all {...} is now outside the release {...} block.

    I think variant.zipAlign.outputFile makes the difference.

提交回复
热议问题