[app] Optimize resources
This commit is contained in:
parent
8f8441b12c
commit
e3eedcf792
|
|
@ -17,6 +17,7 @@
|
||||||
* Copyright (C) 2020 EdXposed Contributors
|
* Copyright (C) 2020 EdXposed Contributors
|
||||||
* Copyright (C) 2021 LSPosed Contributors
|
* Copyright (C) 2021 LSPosed Contributors
|
||||||
*/
|
*/
|
||||||
|
import java.nio.file.Paths
|
||||||
|
|
||||||
apply plugin: 'com.android.application'
|
apply plugin: 'com.android.application'
|
||||||
|
|
||||||
|
|
@ -80,6 +81,29 @@ android {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def optimizeReleaseResources = task('optimizeReleaseResources').doLast {
|
||||||
|
def aapt2 = Paths.get(project.android.sdkDirectory.path, 'build-tools', project.android.buildToolsVersion, 'aapt2')
|
||||||
|
def zip = Paths.get(project.buildDir.path, 'intermediates',
|
||||||
|
'processed_res', 'release', 'out', "resources-release.ap_")
|
||||||
|
def optimized = new File("${zip}.opt")
|
||||||
|
def cmd = exec {
|
||||||
|
commandLine aapt2, 'optimize', '--collapse-resource-names',
|
||||||
|
'--shorten-resource-paths',
|
||||||
|
'-o', optimized, zip
|
||||||
|
ignoreExitValue false
|
||||||
|
}
|
||||||
|
if (cmd.exitValue == 0) {
|
||||||
|
delete(zip)
|
||||||
|
optimized.renameTo("$zip")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.whenTaskAdded { task ->
|
||||||
|
if (task.name == 'processReleaseResources') {
|
||||||
|
task.finalizedBy optimizeReleaseResources
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
|
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
|
||||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue