Beta Cloth and APK are Separated

I am breaking my application on the basis of ABI, and not on density, for example:

splits { abi { enable true reset() include 'x86', 'armeabi', 'armeabi-v7a', 'mips', 'arm64-v8a' universalApk true } } 

I have several options, and 2 types of assembly (debugging and release). I want to put a universal apk file, which has its own libraries for all platforms, on a beta version of a beta version. As far as I understand, this is supported through the ext.betaDistributionApkFilePath attribute.

I can define this either at the buildType level or at the taste level. The problem is that I need both the type of assembly and the taste to choose my option - something like this:

 android.applicationVariants.all { variant -> variant.ext.betaDistributionApkFilePath = "${buildDir}/outputs/apk/app-${variant.productFlavors[0].name}-universal-${variant.buildType.name}.apk" } 

or

 gradle.taskGraph.beforeTask { Task task -> if(task.name ==~ /crashlyticsUploadDistribution.*/) { System.out.println("task name: ${task.name}"); android.applicationVariants.all { variant -> System.out.println("match: crashlyticsUploadDistribution${variant.name}"); if(task.name ==~ /(?i)crashlyticsUploadDistribution${variant.name}/){ ext.betaDistributionApkFilePath = "${buildDir}/outputs/apk/app-${variant.productFlavors[0].name}-universal-${variant.buildType.name}.apk" System.out.println(ext.betaDistributionApkFilePath); } } } 

Unfortunately, this does not work - is there a way to do it now?

+7
source share
1 answer

For each existing variant, you can add an action that will be performed before the Crashlytics tasks and set ext.betaDistributionApkFilePath according to the variant name. Here's what it looks like:

 android.applicationVariants.all { variant -> variant.outputs.each { output -> // Filter is null for universal APKs. def filter = output.getFilter(com.android.build.OutputFile.ABI) if (filter == null) { tasks.findAll { it.name.startsWith( "crashlyticsUploadDistribution${variant.name.capitalize()}") }.each { it.doFirst { ext.betaDistributionApkFilePath = output.outputFile.absolutePath } } tasks.findAll { it.name.startsWith( "crashlyticsUploadSymbols${variant.name.capitalize()}") }.each { it.doFirst { ext.betaDistributionApkFilePath = output.outputFile.absolutePath } } } } } 
+8
source

All Articles