usu*_*ser 11 proguard minify gradle android-studio android-gradle-plugin
我将几个eclipse项目导入Android Studio(v1.1).
在最初的Eclipse环境中,他们使用Proguard进行发布模式.
在Android Studio环境中,这被翻译为build.gradle脚本中的以下内容(通过导入,而不是我):
buildTypes {
release {
minifyEnabled true
proguardFiles 'proguard.cfg'
}
}
Run Code Online (Sandbox Code Playgroud)
我知道这意味着"在release构建中,使用proguard.cfg启用Proguard的缩小".
然而,问题是minify似乎也发生在非发布版本(即调试)中!
这怎么可能?
调试版本的minifyEnabled的默认值是什么?
更新1:感谢下面的答案,我现在知道默认是false.这意味着其他东西正在构建调试版本中缩小的各种模块.
我发布了整个 build.gradle,用于在调试版本中缩小的模块之一:
apply plugin: 'com.android.library'
android {
compileSdkVersion 8
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 8
targetSdkVersion 8
}
buildTypes {
release {
minifyEnabled true
proguardFiles 'proguard.cfg'
}
}
}
Run Code Online (Sandbox Code Playgroud)
整个build.gradle项目本身(即顶层)是:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
}
}
allprojects {
repositories {
jcenter()
}
}
Run Code Online (Sandbox Code Playgroud)
我无法在这里发现任何可以解释在调试版本上强制缩小的内容.
更新2:怀疑应用程序的build(debug)和它所依赖的模块(release?)之间的不匹配,我还检查了左侧面板上的Build Variant视图.所有这些都是debug明确的.
更新3:看来我在Android-Gradle中遇到了错误/限制?
debug当应用程序内置模式时,我真的需要内置模式的所有模块debug.
我有什么想法可以解决这个问题吗?
laa*_*lto 12
调试版本的minifyEnabled的默认值是什么?
其缺省值minifyEnabled是false对所有类型的建设.参考.
然而,问题是minify似乎也发生在非发布版本(即调试)中!
这怎么可能?
您的调试版本可能通过某处的其他定义或您正在使用的外部构建脚本获得proguard处理.
在您更新的问题中,您有一个库项目和一个使用缩小库的应用程序项目,甚至用于调试版本.这是一个"功能".对于解决方案,请考虑问题报告中也提到的以下内容:
通过向其添加以下内容来构建库项目的所有变体build.gradle:
android {
publishNonDefault true
}
Run Code Online (Sandbox Code Playgroud)
在app项目中,选择与构建类型特定的依赖关系
dependencies {
releaseCompile project(path: ':theotherproject', configuration: 'release')
debugCompile project(path: ':theotherproject', configuration: 'debug')
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
28866 次 |
| 最近记录: |