【问题标题】:Could not find method implementation() for arguments [com.google.firebase:firebase-ml-model-interpreter:15.0.0]找不到参数的方法 implementation() [com.google.firebase:firebase-ml-model-interpreter:15.0.0]
【发布时间】:2018-08-10 13:05:21
【问题描述】:

我正在尝试在 Android Studio 中打开现有的 android 项目,gradle 无法构建应用程序,它显示错误为:

错误:强文本在 org.gradle.api.internal 类型的对象上找不到参数 [com.google.firebase:firebase-ml-model-interpreter:15.0.0] 的方法 implementation()。 artifacts.dsl.dependencies.DefaultDependencyHandler。

apply plugin: 'com.android.application'

android {
compileSdkVersion 27
defaultConfig {
    applicationId "com.google.firebase.codelab.mlkit_custommodel"
    minSdkVersion 19
    targetSdkVersion 27
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
aaptOptions {
    noCompress "tflite"
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

implementation 'com.google.firebase:firebase-core:15.0.2'
implementation 'com.google.firebase:firebase-ml-model-interpreter:15.0.0'
 }
   apply plugin: 'com.google.gms.google-services'

【问题讨论】:

    标签: android firebase build.gradle build-dependencies gradle-dependencies


    【解决方案1】:

    正如 AS 建议 could not find method implementation() for arguments 这意味着 gradle 无法识别您在 gradle 中的实现。当使用 compile 方法时,这意味着您使用的是旧版本的 gradle。

    注意:

    因此,解决方案是将您的 gradle 更新到最新版本,然后 再试一次。版本 3.4 或支持方法 implementation 稍后。

    【讨论】:

      【解决方案2】:

      我正在使用

      targetSdkVersion 28
      com.google.firebase: firebase-ml-model-interpreter: 16.0.0
      

      我没有这个问题。尝试更新库。

      【讨论】:

        【解决方案3】:

        要解决这个问题,请更改以下代码行:

        implementation 'com.google.firebase:firebase-core:15.0.2'
        implementation 'com.google.firebase:firebase-ml-model-interpreter:15.0.0'
        

        到

        implementation 'com.google.firebase:firebase-core:16.0.1'
        implementation 'com.google.firebase:firebase-ml-model-interpreter:16.0.0'
        

        更多信息请参见here。

        请同时更新您的 build.gradle 文件(项目),以下依赖项:

        classpath 'com.android.tools.build:gradle:3.1.4'
        classpath 'com.google.gms:google-services:4.0.2'
        

        【讨论】:

          【解决方案4】:

          更新gradle和

          然后:

          在 build.grade(app):

          replace compile -> implementation
          
          repace androidTestCompile ->androidTestImplementation
          
          replace testCompile ->testImplementation
          

          在 build.grade(project):

              allprojects {
                 repositories {
                  jcenter()
                  google() // Google's Maven repository . add this line here<br>
              }
          }
          

          【讨论】:

            【解决方案5】:

            确保您已将 Google maven 存储库添加到您的根 build.gradle

            allprojects {
                // ...
                repositories {
                    // ...
                    google() // Google's Maven repository
                }
            }
            

            【讨论】:

              【解决方案6】:

              评论或删除此行:implementation 'com.google.firebase:firebase-core:15.0.2' 该项目将构建并运行 - 从这里开始。

              这对我有用。

              【讨论】:

                猜你喜欢
                • 2019-02-16
                • 1970-01-01
                • 2018-11-30
                • 1970-01-01
                • 2018-05-24
                • 1970-01-01
                • 2021-02-24
                • 1970-01-01
                • 1970-01-01
                相关资源
                最近更新 更多