AppGeek
AppGeek

Reputation: 137

Adding Gradle build Folder in library

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.

Upvotes: 1

Views: 395

Answers (3)

Gabriele Mariotti
Gabriele Mariotti

Reputation: 363429

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

Upvotes: 1

Tobias S
Tobias S

Reputation: 1275

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.

Upvotes: 0

M090009
M090009

Reputation: 1139

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

Upvotes: 0

Related Questions