gpt4 book ai didi

android - 如何在实验性Gradle插件中使用dexOption?

转载 作者:行者123 更新时间:2023-12-03 05:01:13 25 4
gpt4 key购买 nike

构建代码时出现OutOfMemory错误。我尝试将dexOption添加到我的实验build.gradle文件中,如下所示:

model {

def signConf = new String()

android {
compileSdkVersion = COMPILE_SDK_VERSION as int
buildToolsVersion = BUILD_TOOLS_VERSION

defaultConfig.with {
applicationId = "x.y.z.k"
minSdkVersion.apiLevel = MIN_SDK_VERSION as int
targetSdkVersion.apiLevel = TARGET_SDK_VERSION as int
versionCode = VERSION_CODE as int
versionName = VERSION_NAME
multiDexEnabled = true
testInstrumentationRunner = "android.support.test.runner.AndroidJUnitRunner"


}

dexOptions {
javaMaxHeapSize "2048M"

}
}
}

使用 dexOption我得到以下错误:
Error:Cause:com.android.build.gradle.managed.AndroidConfig_Impl

使用实验性Gradle插件进行编译时,如何添加 dexOption

最佳答案

对我有用的是将dexOptions放在android {}块之外,并将其命名为android.dexOption。

例如。

apply plugin: 'com.android.model.application'

model {
android {
compileSdkVersion = 23
buildToolsVersion = "23.0.3"

defaultConfig {
...
}

ndk {
...
}

buildTypes {
...
}

productFlavors {
...
}
}
android.dexOptions {
javaMaxHeapSize = "2g"
}
}

dependencies {
...
}

关于android - 如何在实验性Gradle插件中使用dexOption?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36912534/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com