【问题标题】:Plugin with id 'com.android.library' not found [duplicate]未找到 ID 为“com.android.library”的插件 [重复]
【发布时间】:2015-09-05 02:10:26
【问题描述】:

当我尝试在 Android Studio 中使用库项目时收到此错误。 build.gradle 中给出此错误的特定行是

apply plugin: 'com.android.library'

我什至尝试将其更改为

apply plugin: 'android-library'

但它仍然不起作用,而是说:Error:(7, 0) Plugin with id 'android-library' not found.

我什至尝试添加:

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

build.gradle的依赖下,还是什么都没有……

有什么帮助吗?

编辑:整个 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")

【问题讨论】:

  • 将 build.gradle 发布到主根目录,将 build.gradle 发布到模块文件夹中。

标签: android android-studio android-gradle-plugin build.gradle android-library


【解决方案1】:

你需要这样写:

apply plugin: 'com.android.application'

在您的文件中也替换此代码:

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

    dependencies {
        classpath 'com.android.tools.build:gradle:1.2.3' // 1.3.0-beta2
    }
}

【讨论】:

  • 现在我得到了这个:错误:(7, 0) 未找到 ID 为 'com.android.application' 的插件。
  • 希望你添加到app的build.gradle,你需要全局编辑。在项目中搜索另一个 build.gradle! @鲍里斯拉夫
  • 我正在编辑项目的 Gradle Scripts 目录下的 build.gradle 文件
  • 错误:(30, 0) 未找到 ID 为 'com.android.application' 的插件。
猜你喜欢
  • 2020-09-15
  • 2016-02-04
  • 1970-01-01
  • 1970-01-01
  • 2016-10-04
  • 2020-03-01
  • 2021-01-08
  • 1970-01-01
  • 2019-08-04
相关资源
最近更新 更多