Vivek Jm
Vivek Jm

Reputation: 121

Could not find method implementation() for arguments [com.google.firebase:firebase-ml-model-interpreter:15.0.0]

I am trying to open existing android project in Android Studio and gradle cannot build the app and it shows the error as:

Error : strong text Could not find method implementation() for arguments [com.google.firebase:firebase-ml-model-interpreter:15.0.0] on object of type org.gradle.api.internal.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'

Upvotes: 2

Views: 16533

Answers (6)

Manyalo
Manyalo

Reputation: 81

Comment or delete this line: implementation 'com.google.firebase:firebase-core:15.0.2' the project will build and run - work your way up from here.

This is what worked for me.

Upvotes: 0

Saurabh Koshatwar
Saurabh Koshatwar

Reputation: 46

Make sure you have added the Google maven respository to your root build.gradle

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

Upvotes: 0

Hồng Phúc
Hồng Phúc

Reputation: 478

Update gradle and

then:

in build.grade(app):

replace compile -> implementation

repace androidTestCompile ->androidTestImplementation

replace testCompile ->testImplementation

in build.grade(project):

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

Upvotes: 0

Alex Mamo
Alex Mamo

Reputation: 138834

To solve this, please change the following lines of code:

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

to

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

See here more informations.

Please also update in your build.gradle file (project), the following dependencies:

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

Upvotes: 0

sanjeev
sanjeev

Reputation: 1675

As AS suggests could not find method implementation() for arguments which means the gradle does not recognize your implementation in gradle. It implies that you are using an old version of gradle, when compile method was used.

NOTE:

So, the solution is to update your gradle to the latest version and try again. Method implementation is supported in versions 3.4 or later.

Upvotes: 1

UgAr0FF
UgAr0FF

Reputation: 825

I'm using

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

And I don't have this problem. Try to update the libraries.

Upvotes: 0

Related Questions