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

來源:互聯網
上載者:User

標籤:

AS升級後,工程會預設把你的gradle版本替換成最新的版本,沒有做到向下相容,runProguard()找不著了

把build.gradle中

 

?
123456 buildTypes {        release {            runProguard false            proguardFiles getDefaultProguardFile(‘proguard-android.txt‘), ‘proguard-rules.pro‘        }    }

替換成:

 

?
123456 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
即如下的配置

12345678 buildTypes {    release {         minifyEnabled false // 替代的方式         ......    }}

runProguard —> minifyEnabled
jniDebuggBuild –> jniDebuggable
zipAlign –> zipAlignEnabled

2,Library projects cannot set applicationId

新版本不能使用applicationId來定義庫module的包名了,要定義在manifest

1234567 defaultConfig {        applicationId "cn.flakor.lib"   <---- 刪除這行        minSdkVersion 15        targetSdkVersion 19        versionCode 1        versionName "1.0"    }
1234 <manifest xmlns:android=" http://schemas.android.com/apk/res/android"        xmlns:tools=" http://schemas.android.com/tools"        package="cn.flakor.lib">...

利用flavor重新命名包名

1234567 android {   ...   productFlavors {       flavor1 {           applicationId ‘cn.flakor.newname‘       }   }

參考(不FQ看不了,有時間翻譯下):

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

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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.