码迷,mamicode.com
首页 > 移动开发 > 详细

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

时间:2016-03-04 23:56:28      阅读:467      评论:0      收藏:0      [点我收藏+]

标签:

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‘
       }
   }

参考(不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()’

标签:

原文地址:http://www.cnblogs.com/exmyth/p/5243739.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!