安卓AS 打包时分开生成32位和64位包

app的gradle中

android {
    splits {
        abi {
            enable true
            reset()
            include 'armeabi-v7a', 'arm64-v8a' //select ABIs to build APKs for
            universalApk true //generate an additional APK that contains all the ABIs
        }
    }

    android.applicationVariants.all { variant ->
        variant.outputs.all { output ->
            def aid = variant.applicationId.split("\\.")
            def name = aid[aid.length - 1]
            def flavor = variant.productFlavors[0].name
            def buildType = env
            def abi = output.getFilter(com.android.build.OutputFile.ABI)
            if (abi == null) abi = "all"//兼容
            def version = variant.versionName
            def versionCode = variant.versionCode
            def date = new Date()
            def formattedDate = date.format('yyyyMMdd_HHmm')
            outputFileName = "${name}" +
                    "${flavor}" +
                    "${buildType}" +
                    "${abi}" +
                    "${"v"}${version}" +
                    "${"b"}${versionCode}" +
                    "${formattedDate}.apk"
            if (variant.buildType.name == "release") {
                variant.getPackageApplicationProvider().get().outputDirectory = new File(project.rootDir.absolutePath
                        + "/releaseOutputs")
            }
        }
    }
}

你可能感兴趣的:(工具类,android,gradle)