问题描述
我想通过ABI用分裂,但仅限于发布版本。这可能吗?我试图通过高清也被设置为false,默认使用EXT变量,变量。此变量的releaseWithLog(和释放)设置为true buildTypes。
但我不知道该怎么摇篮的工作,因为当我添加writeln()与测试消息,调试,releaseWithLog和放和运行的建立,所有的信息都在输出,所以这证实了我,变量splitsEnabled设置为true,虽然我搭建调试 - 我期待值假的调试(而不是使用拆分为调试因此)
应用插件:com.android.application
安卓{
compileSdkVersion 19
buildToolsVersion '20 .0.0
分机{
splitsEnabled = FALSE
}
defaultConfig {
...
}
buildTypes {
调试{
...
}
releaseWithLog {
...
splitsEnabled =真
}
release.initWith(releaseWithLog)
推出 {
...
}
}
...
拆分{
ABI {
的println(splitsEnabled)
使splitsEnabled
复位()
包括86,armeabi-V7A,armeabi
排除x86_64的,MIPS64','arm64-V8A,MIPS
universalApk真
}
}
...
现场为Android的Studio中的一个摇篮任务:
您可以轻松地使用命令行参数摇篮,或者脚本参数解决这个问题。我用-P定义dbgBld'符号,并用它进行调试版本,如:
摇篮-PdbgBld installDebug
我build.gradle文件具有以下拆分命令:
拆分{
ABI {
能!project.hasProperty(dbgBld)
复位()
包括armeabi,armeabi-V7A','86','MIPS
universalApk真
}
}
现在建释放我使用:
摇篮assembleRelease
在'dbgBld'符号没有定义,所以分裂使外地解析为真,我得到5 APK文件。当建立了调试,-PdbgBld已经保存在我的Android Studio配置和我得到的只有一个胖APK进行调试,从而导致更快的调试版本。
格雷格
I want use "splits" by "abi", but only for release build. Is this possible? I try use ext variable and variable by "def" also which is set to false by default. This variable is set to true in buildTypes for releaseWithLog (and release).
But I don't know how Gradle work, because when I add writeln() with test message to "debug", "releaseWithLog" and "release" and run build, all messages are in output, so this confirms me that variable "splitsEnabled" is set to true though I build for debug - and I expect value "false" for debug (and not using splits for debug therefore).
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion '20.0.0'
ext {
splitsEnabled = false
}
defaultConfig {
...
}
buildTypes {
debug {
...
}
releaseWithLog {
...
splitsEnabled = true
}
release.initWith(releaseWithLog)
release {
...
}
}
...
splits {
abi {
println(splitsEnabled)
enable splitsEnabled
reset()
include 'x86', 'armeabi-v7a', 'armeabi'
exclude 'x86_64', 'mips64', 'arm64-v8a', 'mips'
universalApk true
}
}
...
You can solve this easily with a command line argument to Gradle, or the "Script parameters:" field for a Gradle task in Android Studio. I used -P to define 'dbgBld' symbol and used it for debug builds, e.g.:
gradle -PdbgBld installDebug
My build.gradle file has the following splits command:
splits {
abi {
enable !project.hasProperty('dbgBld')
reset()
include 'armeabi', 'armeabi-v7a', 'x86', 'mips'
universalApk true
}
}
Now to build release I use:
gradle assembleRelease
The 'dbgBld' symbol is not defined, so the splits enable field resolves to true and I get 5 APK files. When building for debugging, the -PdbgBld is already saved in my Android Studio configuration and I get only one "fat" APK for debugging, which results in much faster debug builds.
Greg
这篇关于Android的摇篮 - 仅发布可能使用分裂?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!