@@ -4,7 +4,16 @@ plugins {
44 id(" org.jetbrains.kotlin.android" )
55}
66
7- android {
7+ configurations.all {
8+ exclude(group = " com.google.android.play" , module = " core" )
9+ exclude(group = " com.google.android.play" , module = " core-common" )
10+ exclude(group = " com.google.android.play" , module = " feature-delivery" )
11+ exclude(group = " com.google.android.play" , module = " app-update" )
12+ exclude(group = " com.google.android.play" , module = " tasks" )
13+ exclude(group = " com.google.android.play" , module = " split-install" )
14+ }
15+
16+ configure< com.android.build.api.dsl.ApplicationExtension > {
817 namespace = " in.commandlinecoding.elephant"
918 compileSdk = flutter.compileSdkVersion
1019 ndkVersion = flutter.ndkVersion
@@ -24,10 +33,8 @@ android {
2433
2534 buildTypes {
2635 getByName(" release" ) {
27- // Using debug signing for release config as requested in your original setup
2836 signingConfig = signingConfigs.getByName(" debug" )
29-
30- // Critical for tree-shaking and stripping out unneeded classes
37+
3138 isMinifyEnabled = true
3239 isShrinkResources = true
3340
@@ -49,8 +56,47 @@ tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach
4956 }
5057}
5158
52- afterEvaluate {
53- configurations.all {
54- exclude(group = " com.google.android.play" )
59+ val abiCodes = mapOf (" armeabi-v7a" to 1 , " arm64-v8a" to 2 , " x86_64" to 3 )
60+
61+ androidComponents {
62+ onVariants { variant ->
63+ variant.outputs.forEach { output ->
64+ val abi = output.filters.find {
65+ it.filterType == com.android.build.api.variant.FilterConfiguration .FilterType .ABI
66+ }?.identifier
67+ val baseAbiCode = abiCodes[abi]
68+ if (baseAbiCode != null ) {
69+ // Multiplies main version code by 10 and appends the specific architecture suffix matching formula
70+ output.versionCode.set((output.versionCode.get() ? : 1 ) * 10 + baseAbiCode)
71+ }
72+ }
5573 }
5674}
75+
76+ project.afterEvaluate {
77+ tasks.configureEach {
78+ if (name.contains(" minifyReleaseWithR8" ) || name.contains(" minifyReleaseWithProguard" ) || name.contains(" dexBuilderRelease" )) {
79+ doFirst {
80+ logger.lifecycle(" FOSS SANITIZER: Active. Sweeping intermediate files for non-free binaries..." )
81+
82+ val searchDirs = listOf (
83+ File (project.layout.buildDirectory.asFile.get(), " intermediates/classes/release" ),
84+ File (project.layout.buildDirectory.asFile.get(), " intermediates/javac/release" )
85+ )
86+
87+ for (dir in searchDirs) {
88+ if (dir.exists()) {
89+ dir.walkTopDown().forEach { file ->
90+ if (file.isDirectory && file.absolutePath.endsWith(" com/google/android/play/core" )) {
91+ file.deleteRecursively()
92+ logger.lifecycle(" Successfully removed vendor-shaded tracking package: ${file.absolutePath} " )
93+ }
94+ }
95+ }
96+ }
97+ }
98+ }
99+ }
100+ }
101+
102+ dependencies {}
0 commit comments