[英]Multidex Android Library Module
我在gradle项目中有一个已连接Android测试的库模块,但测试APK引用了太多方法,需要进行多索引或应启用ProGuard。
有没有办法为连接的Android测试应用程序启用multidex或ProGuard?
直接在库上启用ProGuard是没有意义的,但如果有一种方法只能为androidTest配置启用它,那就可以很好地工作。
我们确实为应用程序模块启用了ProGuard,因此它可以安全地依赖于此库模块并成功构建应用程序的APK。
由于我只能找到有关使用Multidex支持库的信息,因此很难搜索此问题的解决方案。 我了解如何为典型应用程序启用它。
有没有办法为连接的Android测试应用程序启用multidex或ProGuard?
是的,您只能为使用专用测试构建类型的测试启用ProGuard。 默认的是debug
。 在以下示例中,专用测试构建类型名为minifiedTest
。
android {
defaultConfig {
/* Your configs here. */
// Specify the name of the dedicated test build type.
testBuildType 'minifiedTest'
}
buildTypes {
debug {
// Your debug configurations.
}
release {
// Your release configurations.
}
minifiedTest {
// Use this to get the initial configurations from another build type.
// Some of them will be overridden from the configurations specified in this build type.
// You can avoid to use this or you can get them from your release build type for example.
initWith(debug)
// Enable proguard.
minifyEnabled true
// Specify the proguard file.
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.