解決Gradle DSL method not found: ‘android()’


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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM