本文共 3874 字,大约阅读时间需要 12 分钟。
本文翻译自:
I get an error after updating from my last project. 从我上一个项目更新后出现错误。 Not a problem in my code but I'm having trouble with build.gradle. 我的代码不是问题,但我在build.gradle时遇到问题。 How can I fix it? 我该如何解决?
build.gradle code here: build.gradle代码在这里:
apply plugin: 'android'android { compileSdkVersion 21 buildToolsVersion '20.0.0' packagingOptions { exclude 'META-INF/DEPENDENCIES' exclude 'META-INF/LICENSE' exclude 'META-INF/LICENSE.txt' exclude 'META-INF/license.txt' exclude 'META-INF/NOTICE' exclude 'META-INF/NOTICE.txt' exclude 'META-INF/notice.txt' exclude 'META-INF/ASL2.0' } defaultConfig { applicationId 'com.xxx.axxx' minSdkVersion 14 targetSdkVersion 19 versionCode 6 versionName '1.0' } buildTypes { release { runProguard false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } productFlavors { }}dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:19.+' compile files('libs/commons-codec-1.8.jar') compile files('libs/asmack-android-8-4.0.4.jar') compile 'com.android.support:support-v4:21.0.0' compile 'com.google.code.gson:gson:2.2.4' compile 'com.jakewharton:butterknife:5.1.1'}
Gradle Sync message output: Gradle Sync消息输出:
Error:(27, 0) Gradle DSL method not found: 'runProguard()'**Possible causes:The project 'Atomic4Mobile' may be using a version of Gradle that does not contain the method.**Gradle settings**The build file may be missing a Gradle plugin.**Apply Gradle plugin**
参考:
If you are using version 0.14.0 or higher of the gradle plugin, you should replace "runProguard" with "minifyEnabled" in your build.gradle files. 如果您使用的是gradle插件的0.14.0或更高版本,则应在build.gradle文件中将“ runProguard”替换为“minifyEnabled” 。
runProguard was renamed to minifyEnabled in version 0.14.0. runProguard更名为minifyEnabled在0.14.0版本。 For more info, 有关更多信息,
Using 'minifyEnabled'
instead of 'runProguard'
works properly. 使用'minifyEnabled'
而不是'runProguard'
可以正常工作。
Previous code:
buildTypes { release { runProguard false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' } }
Current code:
buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' } }
Hope this helps. 希望这可以帮助。
If you are migrating to 1.0.0 you need to change the following properties. 如果要迁移到1.0.0,则需要更改以下属性。
In the Project's build.gradle file you need to replace minifyEnabled. 在Project的build.gradle文件中,您需要替换minifyEnabled。
Hence your new build type should be 因此,您的新构建类型应该是
buildTypes { release { minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' }}
Also make sure that gradle version is 1.0.0 like 还要确保gradle版本是1.0.0之类的
classpath 'com.android.tools.build:gradle:1.0.0'
in the build.gradle file. 在build.gradle文件中。
This should solve the problem. 这应该可以解决问题。
Source: 资料来源: :
By changing runProguard to minifyEnabled , part of the issue gets fixed. 通过将runProguard更改为minifyEnabled ,可以解决部分问题。
But the fix can cause "Library Projects cannot set application Id" (you can find the fix for this here ). 但修复可能导致“库项目无法设置应用程序ID”(您可以在此处找到的修复程序, )。
By removing application Id in the build.gradle file, you should be good to go. 通过删除build.gradle文件中的应用程序ID,您应该很高兴。
runProguard has been renamed to minifyEnabled in version 0.14.0 (2014/10/31) or more in Gradle. runProguard已在Gradle版本0.14.0(2014/10/31)或更高版本中重命名为minifyEnabled 。
To fix this, you need to change runProguard to minifyEnabled in the build.gradle file of your project. 要解决此问题,您需要在项目的build.gradle文件中将runProguard更改为minifyEnabled。
转载地址:http://suexb.baihongyu.com/