错误:(22,0)未找到摇篮DSL的方法:“编译() [英] Error:(22,0) Gradle DSL method not found: 'compile()'

查看:146
本文介绍了错误:(22,0)未找到摇篮DSL的方法:“编译()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好我有没有发现一个问题摇篮DSL方法:')编译('。最让我读的讨论表明,我想补充编译com.android.support:support-v4:21.+个人的模块构建文件,并在我的情况下编译com.android.support:support-v4:21。 +'已经存在。如果删除了一个我在最顶层构建文件我得到这个错误添加(<一个href=\"http://stackoverflow.com/questions/28134410/errorartifact-support-v4-jar-com-android-supportsupport-v421-0-3-not-foun?noredirect=1#comment44641164_28134410\">Error:Artifact 支持-v4.jar(com.android.support:support-v4:21.0.3)找不到。Android的工作室1.0.2 )。

Hi guys I'm having a problem Gradle DSL method not found: 'compile()'. Most of the discussions I read suggest that I add compile 'com.android.support:support-v4:21.+' to individual's module build file and in my case the compile 'com.android.support:support-v4:21.+' is already there. If I remove the one I added on the top most level build file I get this error (Error:Artifact 'support-v4.jar (com.android.support:support-v4:21.0.3)' not found. Android studio 1.0.2).

请帮忙,这里有我的文件的gradle:

Please help, here are my gradle files:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

    buildscript {
        repositories {
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:1.0.0'

            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        }
    }

    allprojects {
        repositories {
            jcenter()
        }
    }

dependencies {
    compile 'com.android.support:support-v4:21.+'
}

应用程序文件夹下的文件摇篮:

Gradle file under App folder:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "com.example.ntokozo.myapplication"
        minSdkVersion 15
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.0.3'
    compile 'com.android.support:support-v4:21.0.3'
}

感谢您。

推荐答案

删除相关模块的从顶级的build.gradle文件。

Remove the dependencies block from the top level build.gradle file.

dependencies {
    compile 'com.android.support:support-v4:21.+'
}

也更新SDK文件。

Also update your sdk files.

这篇关于错误:(22,0)未找到摇篮DSL的方法:“编译()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆