【问题标题】:How to fix Plugin with id 'com.github.dcendents.android-maven' not found. in android studio如何修复 ID 为“com.github.dcendents.android-maven”的插件未找到。在安卓工作室
【发布时间】:2015-03-05 06:03:33
【问题描述】:

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

【问题讨论】:

    标签: maven android-studio


    【解决方案1】:

    在顶级 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
    }
    

    【讨论】:

      【解决方案2】:

      这里有两种情况:

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

      这个插件一般用于分发和上传你的库项目到bintaray

      在这种情况下,您所要做的就是使用 gradle pluginma​​ven-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
      

      【讨论】:

      • 版本列表的链接非常宝贵。在 Android Studio gradle 同步中,您不会收到不兼容的警告 - 只是各种可怕的失败!
      • Android Gradle 插件 3.6.0 及更高版本包括对 Maven Publish Gradle 插件的支持,它允许您将构建工件发布到 Apache Maven 存储库。 developer.android.com/studio/build/maven-publish-plugin
      【解决方案3】:

      只需删除“应用插件:'android-maven'”行 在 build.gradle 的开头,

      apply plugin: 'com.android.application'
      apply plugin: 'android-maven'
      
      android {
          compileSdkVersion 23
          buildToolsVersion "23.0.2"
      

      该项目不需要 maven。

      【讨论】:

      • 这是该问题的完美答案。切中要害。这应该被标记为接受的答案
      • 它会产生这个错误 ERROR: Plugin with id 'android-maven' not found
      【解决方案4】:

      尝试将这些行添加到项目的 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'
        

        【讨论】:

          【解决方案6】:

          只需在你的 gradle 文件中添加这两行

          classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
          classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
          

          【讨论】:

            【解决方案7】:

            对于 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"
            }
            

            【讨论】:

              【解决方案8】:

              参考上面贴的这个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 的更新版本。正如git repo for this plugin中的Readme中提到的,dcendents提到他被Android maven插件开发者要求重命名插件名称。

              【讨论】:

                【解决方案9】:

                这完全取决于你的 gradle 版本。请检查https://github.com/dcendents/android-maven-gradle-plugin 我在那里找到了我的解决方案。

                 dependencies {
                    // The gradle plugin and the maven plugin have to be updated after each version of Android
                    // studio comes out
                    classpath 'com.android.tools.build:gradle:3.1.1'
                    classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
                    classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
                }
                

                【讨论】:

                  【解决方案10】:

                  终于尝试三天后我可以解决这个错误

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

                  只需将其复制到您的应用程序模块的 build.gradle 中的依赖项闭包中

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

                  当你在线时完成这个步骤

                  【讨论】:

                  • 但我猜它可以像 admob 添加的那样工作,但不会显示在 xml 设计板中,但是当您尝试运行项目时它会出现
                  • 它可以工作,但在运行时,因为设计是在代码运行时生成的
                  【解决方案11】:

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

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

                  【讨论】:

                  • 赞成的原因很简单。谢谢。
                  【解决方案12】:

                  问题是 android 只是,不知道存储库,您必须像这样指定存储库:

                  buildscript {
                      repositories {
                          maven {
                              url = uri("https://plugins.gradle.org/m2/")
                          }
                      }
                      dependencies {
                          classpath("com.github.dcendents:android-maven-gradle-plugin:2.1")
                      }
                  }
                  
                  apply plugin: 'com.github.dcendents.android-maven'
                  

                  【讨论】:

                    【解决方案13】:

                    在项目级 gradle 文件下添加以下内容

                    dependencies {
                            ...
                            classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
                    
                        }
                    

                    【讨论】:

                    • Jitpack 库需要这个插件
                    【解决方案14】:

                    对于 Gradle 7,我在 build.gradle 模块级别删除了这一行:

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

                    【讨论】:

                      【解决方案15】:

                      升级你的 Github 库版本,因为你的 Gradle 版本和 Github 库版本不匹配。

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

                      【讨论】:

                        【解决方案16】:

                        这可能是由 android sdk 引起的。所以我不知道如何发生它,但我按照这些步骤解决了它。

                        1. 如果您在输入 cordova build 或 run 等时在控制台开头看到这些警告。
                         ANDROID_SDK_ROOT=undefined (recommended setting)
                         ANDROID_HOME=C:\anypath (DEPRECATED)
                        
                        

                        首先需要配置ANDROID_HOME路径 https://cordova.apache.org/docs/en/latest/guide/platforms/android/index.html#setting-environment-variables

                        在windows pc中,你应该从环境变量设置中输入路径。

                        https://www.youtube.com/watch?v=S5wqTSuL3j4(这个视频可能对你有帮助)

                        1. Option-1 然后你可以添加新的gradle版本https://gradle.org/install/
                        2. Option-2 替换 /platforms/android/app/build.gradle 上的 gradle 版本

                          来自classpath 'com.android.tools.build:gradle:X.X.Xclasspath 'com.android.tools.build:gradle:3.0.1

                          你可以通过输入命令编辑器找到正确的gradle版本:

                          gradlew --versiongradle --version

                          或者在你的项目中检查这个文件然后找到“distributionUrl” 平台\android\gradle\wrapper\gradle-wrapper.properties distributionUrl=\https://services.gradle.org/distributions/gradle-4.4-all.zip

                        希望对你有帮助。

                        【讨论】:

                          猜你喜欢
                          • 1970-01-01
                          • 2016-02-12
                          • 2021-12-17
                          • 1970-01-01
                          • 2018-05-13
                          • 1970-01-01
                          • 2021-03-14
                          • 2017-03-22
                          • 1970-01-01
                          相关资源
                          最近更新 更多