如何修复未找到id“com.github.dcendents.android-maven”的插件。在android工作室

问题描述 投票:31回答:10

我正在android studio中创建一个android应用程序。我正在为我的项目添加一个库,该库是从here下载的。当我将这个库添加到我的项目时,它显示一个错误,名为“Error:(2,0)插件,ID为'com.github.dcendents.android-maven'未找到。”。请告诉我如何解决它。

maven android-studio
10个回答
39
投票

在顶级build.gradle依赖项中,粘贴此类路径。我想知道为什么我不能在网站上看到这种方法。无论如何,我用这种方式修复它。

dependencies {
    //YOUR DEPEDENCIES
    classpath 'com.github.dcendents:android-maven-plugin:1.2'
    classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2'
    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}

0
投票

如果在您的项目中任何使用此id的模块,那么您必须在项目级build.gradle文件中声明以下两个依赖项 -

classpath 'com.github.dcendents:android-maven-gradle-plugin:1.
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2'

15
投票

这里有两种情况:

  1. 如果您在模块级gradle中使用apply plugin: 'com.github.dcendents.android-maven'

此插件通常用于将您的库项目分发和上传到bintaray。

在这种情况下,您所要做的就是使用gradle插件和maven-gradle-plugin的正确组合。

以下版本的组合对我有用:

内部项目级别gradle

classpath 'com.android.tools.build:gradle:2.3.0+'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'

并在gradle-wrapper.properties中

distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip

在模块级gradle:apply plugin: 'com.github.dcendents.android-maven'

您可以从Github查看兼容版本列表

  1. 如果你没有使用它,就像你的情况一样,只需删除即可 classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0' classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'

apply plugin: com.github.dcendents.android-maven

8
投票

只需在build.gradle的开头删除“apply plugin:'android-maven'”行,

apply plugin: 'com.android.application'
apply plugin: 'android-maven'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

该项目不需要专家。


8
投票

尝试将这些行添加到项目的build.gradle文件到依赖项块中:

classpath 'com.github.dcendents:android-maven-plugin:1.2'

像这样

dependencies {
    classpath 'com.android.tools.build:gradle:1.3.0'
    classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2'
    classpath 'com.github.dcendents:android-maven-plugin:1.2'
}

它对我有用。


5
投票

在project.gradle依赖项中添加以下行:

classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2'

2
投票

参考上面发布的这个answer,我在使用它后遇到了另一个问题No service of type Factory available in ProjectScopeServices

我通过在项目gradle的依赖项中包含com.github.dcendents:android-maven-gradle-plugin:1.4.1(如this answer中提到的上述链接问题)而不是com.github.dcendents:android-maven-plugin:1.2来修复它。

不要太困惑。 android-maven-gradle-plugin:1.4.1只是android-maven-plugin:1.2的更新版本。正如在Readmegit repo for this plugin中所提到的,dcendents提到他被Android maven插件开发者重命名为插件名称。


1
投票

最后我可以在尝试三天后解决这个错误

解决方案非常简单,只需从项目中完全删除模块或库项目,然后使用gradle依赖项。

只需在依赖关系闭包内的app模块的build.gradle中复制它

dependencies {
 // YOUR OTHER DEPENDENCIES
 compile 'com.github.navasmdc:MaterialDesign:1.+@aar'} 

当你在线时成功完成这一步骤


1
投票

对于Gradle 4.1+,您可以在项目级别的build.gradle中执行:

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
    }
}

plugins {
    id "com.jfrog.bintray" version "1.7.3"
    id "com.github.dcendents.android-maven" version "2.0"
}

0
投票

升级您的Github库版本作为您的Gradle版本和Github库版本不匹配。

在这里检查版本兼容性:https://github.com/dcendents/android-maven-gradle-plugin

© www.soinside.com 2019 - 2024. All rights reserved.