美文网首页
Android Gradle 分别构建不同abi的方法

Android Gradle 分别构建不同abi的方法

作者: Visualing | 来源:发表于2021-11-29 17:28 被阅读0次

    Android Gradle 分别构建不同abi的方法

    android {
        splits {
            abi {
                reset()
                enable enableSeparateBuildPerCPUArchitecture
                universalApk false  // If true, also generate a universal APK
                include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
            }
        }
    
        // applicationVariants are e.g. debug, release
        applicationVariants.all { variant ->
            variant.outputs.each { output ->
                // For each separate APK per architecture, set a unique version code as described here:
                // https://developer.android.com/studio/build/configure-apk-splits.html
                // Example: versionCode 1 will generate 1001 for armeabi-v7a, 1002 for x86, etc.
                def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
                def abi = output.getFilter(OutputFile.ABI)
                if (abi != null) {  // null for the universal-debug, universal-release variants
                    output.versionCodeOverride =
                            defaultConfig.versionCode * 1000 + versionCodes.get(abi)
                }
            }
        }
    }
    

    相关文章

      网友评论

          本文标题:Android Gradle 分别构建不同abi的方法

          本文链接:https://www.haomeiwen.com/subject/tsylxrtx.html