A gradle pulgin for Android Application project. When you import many dependency libs or aars, some redundant resources make your apk pretty huge. ApkEditor can exclude resources from APK, aim to reduce the APK's volume as more as possible.
Though, it needs your ability of distinguishing the resources which is useful in runtime or not. In bad case, your program crashed.
-
ApkEditor checks the android application's environment. So make sure the android plugin
com.android.applicationhave been applied. -
Apply to your project:
buildscript { repositories { jcenter() } dependencies { classpath 'com.mapeiyu.apkeditor:apkeditor:1.0.3' } } apply plugin: 'apkeditor' -
Use the
apkeditorscope:apkeditor { exclude '/assets/**/sb/*.so' release { exclude 'lib/armeabi/**' } //suppose you have a flavor named black blackDebug { exclude '/res/layout/**' exclude 'res/drawable*/*.xml' } } -
Then build or install as normal. The Apk generated will packaged without above rousources which match the rules.
-
The
excludevarient in the root scope apply to all the buildType and flavors. -
The
excludevarient under the param as 'release' 'debug' 'backDebug', appliy to specified apk. -
The
excludevarient can be execute multi times. -
The rule of
excludevalue folows the convention of Java Filesystem API, and it's come from the APK's file system. (You could get it by unzip the apk, or from the android studioBuild->Analyze APK...) -
Don't care about the first
/. All the rule is OK. -
ApkEditor can't effect on below files which is essential
- /META-INF/**
- resources.arsc
- AndroidManifest.xml
-
Different from the Android Plugin of scope PackagingOptions
- As tested PackagingOptions do not effect on '/res/', '/assets/', '.classes'
- It's rule is not so friendly with multi flavors
- You can get the sources from the GITHUB.
- Visit my personal blog 马培羽
- Email mason.mpy@gmail.com
Copyright 2017 Mapeiyu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.