我使用的是带有gradle'com.android.tools.build:gradle:0.14.+'
的android studio 0.9.3
应用插件:'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion '20.0.0'
defaultConfig {
applicationId "xxx.xxx.xxx"
minSdkVersion 16
targetSdkVersion 19
versionCode 1
versionName "1.0.11"
}
signingConfigs{
releaseConfig{
storeFile file("xxxxxxx")
storePassword = "xxxx"
keyAlias = "xxxx"
keyPassword = "xxxx"
}
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.releaseConfig
// adds version to file name
applicationVariants.all { variant ->
def file = variant.outputFile
variant.outputFile = new File(file.parent, file.name.replace(".apk", "-" + defaultConfig.versionName + ".apk"))
}
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
// You must install or update the Support Repository through the SDK manager to use this dependency.
// You must install or update the Support Repository through the SDK manager to use this dependency.
// You must install or update the Google Repository through the SDK manager to use this dependency.
// You must install or update the Support Repository through the SDK manager to use this dependency.
compile 'com.android.support:support-v4:19.+'
compile 'com.android.support:appcompat-v7:19.+'
compile 'com.mcxiaoke.volley:library:1.0.6'
compile 'com.google.code.gson:gson:2.2.+'
}
怎么解决?
据我所知,runproguard
被minifyenabled
替换。我仍然不确定如何定义proguard的配置,但谷歌搜索应该能帮助您找到答案。
编辑:
简而言之:他们使用了一个更复杂的版本:
applicationVariants.all { variant ->
variant.outputs.each { output ->
def apk = output.outputFile;
def newName;
// newName = apk.name.replace(".apk", "-v" + defaultConfig.versionName + "-" + variant.buildType.name.toUpperCase() + ".apk");
if (variant.buildType.name == "release") {
newName = apk.name.replace(".apk", "-v" + defaultConfig.versionName + "-release.apk");
} else {
newName = apk.name.replace(".apk", "-v" + defaultConfig.versionName + "-beta.apk");
}
output.outputFile = new File(apk.parentFile, newName);
if (output.zipAlign) {
output.outputFile = new File(apk.parentFile, newName.replace("-unaligned", ""));
}
logger.info('INFO: Set outputFile to ' + output.outputFile + " for [" + output.name + "]");
}
}
我安装了最新版本的Android Studio,并导入了一个较旧的项目。当我尝试打开它时会出现以下错误:
我正在尝试在我的android gradle文件中添加“Thow StopExecutionException”: 我使用现有解决方案:
任何解决此问题的建议:我在android studio导入Project后得到此错误 错误:(16,0)找不到Gradle DSL方法:'android()'可能原因: 有一个条形通知,上面写着:Gradle项目同步失败。基本功能(如:编辑,调试)将不能正常工作。 请帮我解决这个问题。谢了!
错误: 错误:(22,0)找不到Gradle DSL方法:“multiDexEnabled()”可能的原因: