【问题标题】:Error:(22,0) Gradle DSL method not found: 'compile()'错误:(22,0) Gradle DSL 方法未找到:'compile()'
【发布时间】:2015-03-24 00:42:43
【问题描述】:

大家好,我遇到了一个问题 Gradle DSL 方法未找到:'compile()'。我阅读的大多数讨论都建议我将 compile 'com.android.support:support-v4:21.+' 添加到个人的模块构建文件中,在我的情况下是 compile 'com.android.support:support-v4:21。 +' 已经在那里了。如果我删除我在最顶层构建文件中添加的那个,我会收到此错误 (Error:Artifact 'support-v4.jar (com.android.support:support-v4:21.0.3)' not found. Android studio 1.0.2)。

请帮忙,这是我的 gradle 文件:

// 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.+'
}

App文件夹下的Gradle文件:

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

谢谢。

【问题讨论】:

    标签: android android-studio android-gradle-plugin


    【解决方案1】:

    从顶层 build.gradle 文件中删除 依赖块

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

    同时更新您的 sdk 文件。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-19
      • 2015-02-21
      • 2017-12-10
      • 1970-01-01
      相关资源
      最近更新 更多