简体   繁体   中英

Failed to apply plugin [id 'com.android.library']

I try to compile a Android Project which uses another library called HoloGraphLibrary. But when I want to compile the following error occurs:

Plugin is too old, please update to a more recent version, or set ANDROID_DAILY_OVERRIDE environment variable to "9e19705c8c53c2712ca27200bfa349e4757e2264"

Error:(1, 1) A problem occurred evaluating project ':HoloGraphLibrary'.

Failed to apply plugin [id 'com.android.library'] Could not create plugin of type 'LibraryPlugin'.

The source of that error is:

apply plugin: 'com.android.library'

android {
    compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
    buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION

    sourceSets {
        main {
            java.srcDirs = ['src']
            res.srcDirs = ['res']
            manifest.srcFile 'AndroidManifest.xml'
        }
    }
}

which is the build.gradle of the library. The build.gradle of the app looks as follows:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion '19.1.0'
    defaultConfig {
        applicationId "XXXXXXXXXXX"
        minSdkVersion 14
        targetSdkVersion 21
        versionCode 2
        versionName '1.0.1'
    }
buildTypes {
    release {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
sourceSets {
    main {
        res.srcDirs = ['src/main/res', 'src/main/res/tut', 'src/main/res/tutorial']
        resources.srcDirs = ['src/main/resources', 'src/main/resources/te']
    }
}
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:21.0.3'
    compile project(":HoloGraphLibrary")
}

I just don't see how i can fix this. Any hints?

Thank you

--------------- EDIT ----------------

This is the top level gradle file.

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.0-beta1'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

Unfortunately, the suggestion of GK did not work!

I have even tried to set the ANDROID_DAILY_OVERRIDE variable to what it has said to, but again the same error.

Well I just solved the issue by replacing

apply plugin: 'com.android.library'

with its deprecated version

apply plugin: 'android-library'

That seems to work for now, but I don't think this is the optimal solution, so I'm open to better ones.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM