How to fix "Plugin with id 'com.android.library' not found." issue with Android Libraries

Normal structure of build.gradle for an Android library looks like this:
apply plugin: 'com.android.library'
android {
    compileSdkVersion 23 
    buildToolsVersion '23.0.0'
    defaultConfig {
        minSdkVersion 11 
       targetSdkVersion 23 
       versionCode 1 
       versionName "1.0" 
    }
    buildTypes {
        release {
            /runProguard false 
           proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'        }
    }
}

You might encounter dreaded "Plugin with id 'com.android.library' not found." error while importing this library project as an independent project in Android Studio.

After researching for a while around the web, I figured out what was missing. Actually, a way to tell your library project's gradle file to source to get the plug-in. Pretty straight forward, but may not occur when needed.

So, don't forget to add these lines at the beginning of the build.gradle for your Android library:

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

apply plugin: 'com.android.library'
....

 

Comments

  1. It is showing me a warning that dependencies cannot be applied to groovy.lang.closure

    ReplyDelete

Post a Comment

Popular posts from this blog

Setting up .netrc file on Mac OS X (Lion) for Git

How did I setup SSL with HTTPClient-4.1.2