1

I am trying to import a project as a library in android studio. I configured the build.gradle and the setting folder but I kept getting an error message saying that the configuration with the name default was not found. After doing research I found out that, the library requires a build.gradle folder. How do I add a build .gradle folder ? Please help me out.

AppGeek
  • 137
  • 4
  • 13

3 Answers3

1

You should have this type of structure:

root
  build.gradle
  settings.gradle
  lib
    build.gradle
  app  //optional
    build.gradle

In settings.gradle:

include ':lib' , ':app'

In lib/build.gradle something like this:

apply plugin: 'com.android.library'

repositories {
    mavenCentral()
}

android {
    compileSdkVersion 22
    buildToolsVersion 22.0.1

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 22
        versionName 1
        versionCode 1
    }
}

In app/build.gradle something like this:

apply plugin: 'com.android.application'

repositories {
    mavenCentral()
}

android {
    compileSdkVersion 22
    buildToolsVersion 22.0.1

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 22
        versionName 1
        versionCode 1

    }

}

dependencies {
    compile project(':lib')
}
Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
0

Checkout this answer by @froger_mcs, he included a full tutorial of importing a library here, the part that you're looking for is part 7. hope this helps

Community
  • 1
  • 1
M090009
  • 1,129
  • 11
  • 20
0

Can you import your project as gradle project in Android Studio? Per default, every new project has a gradle file. This file only is missing, when you are coding without android studio.

Tobias S
  • 1,275
  • 8
  • 23