Last active
September 30, 2020 02:38
-
-
Save mmadev/97716b29753aed299003 to your computer and use it in GitHub Desktop.
Add multidex keep file support in the build.gradle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
android.applicationVariants.all { variant -> | |
task "fix${variant.name.capitalize()}MainDexClassList" << { | |
logger.info "Fixing main dex keep file for $variant.name" | |
File keepFile = new File("$buildDir/intermediates/multi-dex/$variant.buildType.name/maindexlist.txt") | |
keepFile.withWriterAppend { w -> | |
// Get a reader for the input file | |
w.append('\n') | |
new File("${projectDir}/multidex.keep").withReader { r -> | |
// And write data from the input into the output | |
w << r << '\n' | |
} | |
logger.info "Updated main dex keep file for ${keepFile.getAbsolutePath()}\n$keepFile.text" | |
} | |
} | |
} | |
tasks.whenTaskAdded { task -> | |
android.applicationVariants.all { variant -> | |
if (task.name == "create${variant.name.capitalize()}MainDexClassList") { | |
task.finalizedBy "fix${variant.name.capitalize()}MainDexClassList" | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment