【问题标题】:Failed to apply plugin [id 'com.android.library']无法应用插件 [id 'com.android.library']
【发布时间】:2016-10-04 17:08:29
【问题描述】:

我尝试编译一个使用另一个名为 HoloGraphLibrary 的库的 Android 项目。但是当我想编译时出现以下错误:

插件太旧,请更新到最新版本,或将 ANDROID_DAILY_OVERRIDE 环境变量设置为“9e19705c8c53c2712ca27200bfa349e4757e2264”

错误:(1, 1) 评估项目 ':HoloGraphLibrary' 时出现问题。

无法应用插件 [id 'com.android.library'] 无法创建“LibraryPlugin”类型的插件。

该错误的来源是:

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

这是库的 build.gradle。该应用的 build.gradle 如下所示:

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

我只是不知道如何解决这个问题。有什么提示吗?

谢谢

--------------- 编辑-----

这是顶级 gradle 文件。

// 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()
    }
}

不幸的是,G.K. 的建议。没用!

我什至尝试将 ANDROID_DAILY_OVERRIDE 变量设置为它所说的,但同样的错误。

【问题讨论】:

  • This 可能会帮助你,
  • 发布根级文件

标签: java android android-studio gradle


【解决方案1】:

我刚刚通过替换解决了这个问题

apply plugin: 'com.android.library'

及其已弃用的版本

apply plugin: 'android-library'

目前这似乎可行,但我认为这不是最佳解决方案,因此我愿意接受更好的解决方案。

【讨论】:

  • android-library 已弃用 :(
猜你喜欢
  • 2020-09-15
  • 2015-09-05
  • 2020-03-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-11-04
相关资源
最近更新 更多