Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Plugin with id 'com.android.library' not found [duplicate]

I am receiving this error, when I try to use a library project in Android Studio. The specific line in build.gradle that gives this error is

apply plugin: 'com.android.library'

I even tried changing it to

apply plugin: 'android-library'

Bu it still doesn't work, instead it says: Error:(7, 0) Plugin with id 'android-library' not found.

I even tried to add:

classpath 'com.android.tools.build:gradle:1.2.3.+' 

under dependencies in build.gradle, and still nothing...

Any help?

EDIT: The whole build.gradle

    // This buildscript will assemble the MoPub SDK into an AAR.

repositories {
    jcenter()
}

apply plugin: 'android-library'

group = 'com.mopub'

description = '''MoPub SDK'''

android {
    compileSdkVersion 22
    buildToolsVersion '22.0.1'

    defaultConfig {
        versionCode 25
        versionName "3.8.0"
        minSdkVersion 9
        targetSdkVersion 22
        consumerProguardFiles 'proguard.txt'
    }

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src/main/java']
            resources.srcDirs = ['src/main/java']
            aidl.srcDirs = ['src/main']
            renderscript.srcDirs = ['src/main']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), file('proguard.txt')
        }
    }

    // Note: You will also need a local.properties file to set the location of the SDK in the same 
    // way that the existing SDK requires, using the sdk.dir property.
    // Alternatively, you can set an environment variable called ANDROID_HOME. There is no 
    // difference between the two methods, you can use the one you prefer.
}

dependencies {
    classpath 'com.android.tools.build:gradle:1.2.3.+'
    compile 'com.android.support:support-v4:22.0.0'
    compile 'com.android.support:support-annotations:22.0.0'
    compile 'com.mopub.volley:mopub-volley:1.1.0'
}

// Don't run the Robolectric Unit Tests.
check.dependsOn.remove("test")
check.dependsOn.remove("unitTest")
check.dependsOn.remove("testDebug")
check.dependsOn.remove("unitTestDebug")
like image 255
Borislav Avatar asked Jun 19 '15 07:06

Borislav


1 Answers

You need to write this:

apply plugin: 'com.android.application'

Replace this code in your file too:

buildscript {
    repositories {
        mavenCentral() // or jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:1.2.3' // 1.3.0-beta2
    }
}
like image 199
Sohil R. Memon Avatar answered Nov 07 '22 18:11

Sohil R. Memon