AS升級后,工程會默認把你的gradle版本替換成最新的版本,沒有做到向下兼容,runProguard()找不着了
把build.gradle中
1
2
3
4
5
6
|
buildTypes {
release {
runProguard
false
proguardFiles getDefaultProguardFile(
'proguard-android.txt'
),
'proguard-rules.pro'
}
}
|
替換成:
1
2
3
4
5
6
|
buildTypes {
release {
minifyEnabled
false
proguardFiles getDefaultProguardFile(
'proguard-android.txt'
),
'proguard-rules.pro'
}
}
|
更多版本問題參考:
http://www.flakor.cn/2014-12-23-849.html?utm_source=tuicool
今天將android studio升級到了新版本,不出意外又出現各種問題
1,Gradle DSL method not found: ‘runProguard()’
runProguard函數已經被廢棄並且停止使用了
改成minifyEnabled
即如下的配置
1
2
3
4
5
6
7
8
|
buildTypes {
release {
minifyEnabled false // 替代的方式
......
}
}
|
runProguard —> minifyEnabled
jniDebuggBuild –> jniDebuggable
zipAlign –> zipAlignEnabled
2,Library projects cannot set applicationId
新版本不能使用applicationId來定義庫module的包名了,要定義在manifest
1
2
3
4
5
6
7
|
defaultConfig {
applicationId "cn.flakor.lib" <---- 刪除這行
minSdkVersion 15
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
|
1
2
3
4
|
<manifest xmlns:android="
http://schemas.android.com/apk/res/android"
xmlns:tools="
http://schemas.android.com/tools"
package="cn.flakor.lib">
...
|
利用flavor重命名包名
1
2
3
4
5
6
7
|
android {
...
productFlavors {
flavor1 {
applicationId 'cn.flakor.newname'
}
}
|
參考(不翻牆看不了,有時間翻譯下):
http://tools.android.com/tech-docs/new-build-system/user-guide
http://tools.android.com/tech-docs/new-build-system/migrating-to-1-0-0