Search code examples
androidandroid-studioandroid-gradle-pluginbuild.gradlebuild-error

Error:Configuration with name 'default' not found when trying to import project as library into Android Studio


I checked all the other threads about this topic but couldn't find an answer. I am trying to import the Twoway View Project as a library into Android Studio.

Both projects run fine on their own but I always get the same Gradle Error: Error:Configuration with name 'default' not found when trying to import.

I have the project copied into a "libraries" directory in the root folder of my project and the following gradle structure:

settings.gradle of my project:

include ':libraries:twoway-view-master',':app'

build.gradle of "app":

  apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "app.com.jeldrik.teacherslittlehelper"
        minSdkVersion 13
        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 project(':libraries:twoway-view-master')

and in twoway-view-master build.gradle:

buildscript {
    repositories {
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:1.0.0'
    }
}

Solution

  • That twowayview-master build.gradle file isn't a buildscript for a standalone module; it lacks any sort of apply plugin statement that would tell Gradle how it should compile something. This looks like the top-level build file of a multimodule-structured project. In your settings.gradle file, you should point at the module in the project you're trying to include, not the build file at the top level.