Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Fix “Error Could not find method implementation() for arguments [com.android.support:appcompat-v7:26.0.0]” in Android Studio

  • Last Updated : 16 Jun, 2021

Implementation is a dependency configuration used for library declaration and was introduced in the Android Gradle Plugin 3.0 by Google. Implementation dependencies are declared in this configuration which is internal and not meant for consumer exposure. The main reason for “Could not find method implementation() for arguments [com.android.support:appcompat-v7:26.0.0]”” error is that the Gradle cannot recognize the implementation configuration. In this article, we will be discussing 5 different methods to solve this error.

  • Method 1: Update to the latest Gradle version
  • Method 2: Change “implementation” to “compile”
  • Method 3: Move dependencies to module build.gradle
  • Method 4: Change apply plugin: “java” to “java-library”
  • Method 5: Change “implementationSdkVersion” to “compileSdkVersion”

Method 1:  Update to the latest Gradle version

In case you are using the “implementation” configuration in an older version of Gradle, the Gradle will not recognize it and throw this error. Hence updating Gradle and Gradle build plugin to the latest version can help solve this issue. 

Want a more fast-paced & competitive environment to learn the fundamentals of Android?
Click here to head to a guide uniquely curated by our experts with the aim to make you industry ready in no time!

Step 1: Navigate to  app > Gradle Script > build.gradle (Project: app). Now inside the “dependencies” block, update the classpath to the latest version of the Gradle build plugin. 

dependencies { classpath "com.android.tools.build:gradle:4.0.2" }



Step 2: Now navigate to app > Gradle Script > gradle-wrapper.properties and update the “distributionUrl” to the latest version of Gradle. After adding this code sync your project to solve this issue. 

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

Method 2: Change “implementation” to “compile”

If you are using the “implementation” configuration in a Gradle Plugin version less than 3.0, the Gradle will not recognize it and will throw this error. Hence changing “implementation” to “compile” would work. Navigate to app > Gradle Script > build.gradle (Module:app). Inside the dependencies block change “implementation” to “compile“, “testImplementation” to “testCompile” and “androidTestImplementation” to “androidTestCompile“. 

dependencies {
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile 'androidx.appcompat:appcompat:1.3.0'
    compile 'androidx.constraintlayout:constraintlayout:2.0.4'
    compile 'com.google.firebase:firebase-database:20.0.0'
    compile 'com.google.firebase:firebase-analytics'
    compile platform('com.google.firebase:firebase-bom:28.0.1')
    compile 'com.google.android.material:material:1.3.0'
    compile 'com.google.android:flexbox:2.0.1'
    compile 'androidx.cardview:cardview:1.0.0'
    compile 'com.google.firebase:firebase-storage:20.0.0'
    testCompile 'junit:junit:4.12'
    androidTestCompile  'androidx.test.ext:junit:1.1.2'
    androidTestCompile 'androidx.test.espresso:espresso-core:3.3.0'
}

Method 3: Move dependencies to module build.gradle

In Android Studio, there is two build.gradle files. One is for the Project level and another one for the Module level. If application dependencies are added in the Project level build.gradle file, it throws the error “Could not find implementation() method”. Adding these dependencies into the module build.gradle can help solve this issue.

Method 4: Change apply plugin: “java” to “java-library” 

The Java Library plugin expands the capabilities of the Java plugin by providing specific knowledge about Java libraries. Change the code inside the Module level build.gradle from 

apply plugin: 'java'

to 

apply plugin: 'java-library'

After adding this code sync your project to solve this issue. 

Method 5: Change “implementationSdkVersion” to “compileSdkVersion”

The version of the compiler used while building the app is determined by the “compileSdkVersion” while there is no such method as “implementationSdkVersion” in Gradle. Hence changing “implementationSdkVersion” to “compileSdkVersion” can solve this issue. Navigate to  app > Gradle Script > build.gradle (Module:app). Change the code from

android {
   implementationSdkVersion 30
   .......
   }

to

android {
   compileSdkVersion 30
   .......
   }

After adding this code sync your project to solve this issue. 

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!