错误:找不到名称为“default”的配置。谷歌不知道

时间:2016-10-21 18:46:56

标签: java android android-studio import-libraries

您好我遇到此错误

Error:Configuration with name 'default' not found.

我的build.gradle:projeck

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

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

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

我的build.gradle:app

   apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.3"
    defaultConfig {
        applicationId "com.atry.paradox.listdrop"
        minSdkVersion 15
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile project(':library2')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:24.2.1'
    testCompile 'junit:junit:4.12'
}

my settings.gradle

include ':app', ':library2'

我在google上寻找这个错误,但我找到了将copy2文件复制到主文件的建议。我在同一个文件中有库2,我有app,build,gradle ......

请问我在哪里做错误?

谢谢

1 个答案:

答案 0 :(得分:0)

取决于settings.gradle文件:

include ':app', ':library2'

Gradle正在寻找2个项目(app和library2) 每个项目都必须包含build.gradle文件。

root
|--build.gradle
|--settings.gradle
|--app
|----build.gradle
|--library2
|----build.gradle

此错误:

   Error:Configuration with name 'default' not found.
如果一个(或更多)模块没有build.gradle文件,则会发生

检查您的library2文件夹是否具有build.gradle和正确的结构。