[android] Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support:appcompat-v7:26.1.0

Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support:appcompat-v7:26.1.0.

Could not resolve com.android.support:appcompat-v7:26.1.0.

Required by: project :app

No cached version of com.android.support:appcompat-v7:26.1.0 available for offline mode.

Error log:

Could not resolve all files for configuration ':app:debugCompileClasspath'.
Could not resolve com.android.support:appcompat-v7:26.1.0.
Required by:
project :app
No cached version of com.android.support:appcompat-v7:26.1.0 available for offline mode.
No cached version of com.android.support:appcompat-v7:26.1.0 available for offline mode.
Could not resolve com.android.support.constraint:constraint-layout:1.1.0-beta3.
Required by:
project :app
No cached version of com.android.support.constraint:constraint-layout:1.1.0-beta3 available for offline mode.
No cached version of com.android.support.constraint:constraint-layout:1.1.0-beta3 available for offline mode.
Could not resolve com.android.support:design:26.1.0.
Required by:
project :app
No cached version of com.android.support:design:26.1.0 available for offline mode.
No cached version of com.android.support:design:26.1.0 available for offline mode.
Could not resolve com.android.support:cardview-v7:26.1.0.
Required by:
project :app
No cached version of com.android.support:cardview-v7:26.1.0 available for offline mode.
No cached version of com.android.support:cardview-v7:26.1.0 available for offline mode.
Could not resolve com.google.android.gms:play-services-ads:11.4.2.
Required by:
project :app
No cached version of com.google.android.gms:play-services-ads:11.4.2 available for offline mode.
No cached version of com.google.android.gms:play-services-ads:11.4.2 available for offline mode.
Could not resolve com.android.support:support-v4:26.1.0.
Required by:
project :app
No cached version of com.android.support:support-v4:26.1.0 available for offline mode.
No cached version of com.android.support:support-v4:26.1.0 available for offline mode.

Error log image:

Click here for image

This question is related to android android-studio gradle android-gradle-plugin

The answer is


use Invalidate Caches/Restart it will works for you and make sure that your gradle offline sync option is not enabled


I solved the problem. In Home Ubuntu, I deleted the .gradle folder and downloaded it again. I hope it is useful


For me the cause was incorrect url for jcenter. To solve it I simply changed url for app and proect level build.gradle

from

jcenter { url "http://jcenter.bintray.com/"}

to

jcenter()

Below is a workaround demo image of ; Uncheck Offline work option by going to:

File -> Settings -> Build, Execution, Deployment -> Gradle

enter image description here

If above workaround not works then try this:

  1. Open the build.gradle file for your application.

  2. Make sure that the repositories section includes a maven section with the "https://maven.google.com" endpoint. For example:

    allprojects {
         repositories {
             jcenter()
             maven {
                 url "https://maven.google.com"
             }
         }
    }
    
  3. Add the support library to the dependencies section. For example, to add the v4 core-utils library, add the following lines:

    dependencies {
        ...
        compile "com.android.support:support-core-utils:27.1.0"
    }
    

Caution: Using dynamic dependencies (for example, palette-v7:23.0.+) can cause unexpected version updates and regression incompatibilities. We recommend that you explicitly specify a library version (for example, palette-v7:27.1.0).

Manifest Declaration Changes

Specifically, you should update the android:minSdkVersion element of the <uses-sdk> tag in the manifest to the new, lower version number, as shown below:

<uses-sdk
  android:minSdkVersion="14"
  android:targetSdkVersion="23" />

If you are using Gradle build files, the minSdkVersion setting in the build file overrides the manifest settings.

apply plugin: 'com.android.application'

android {
   ...
      defaultConfig {
            minSdkVersion 16
            ...
        }
        ...
    }

Following Android Developer Library Support.


Go to File->Other Settings->Preferences for New Projects->Build, Execution, Deployment->Build Tools->Gradle->Uncheck Offline work option.


If you are getting this same error after adding dynamic module then don't worry follow this:

  • Add productFlavors in your build.gradle(dynamic- module)

    productFlavors {
    flavorDimensions "default"
    stage {
       // to do
    }
    prod {
       // to do
    
     }
    }
    

Invalidate Cache / Restart from File option.

Just unchecking offline mode did not work for me.


I ran into the same issue and adding mavenCentral() in the repositories block of my build.gradle file worked for me. I had Offline work unchecked and adding maven { url "https://maven.google.com" }. Adding this answer for the lost souls that find themselves at end of this thread.


Adding this in project gradle worked for me

allprojects {
 repositories {
     jcenter()
     maven {
         url "https://maven.google.com" // specifically this worked 
     }
 }}

From the documentations:

Add the support library to the dependencies section. For example, to add the v4 core-utils library, add the following lines:

dependencies {
    ...
    implementation "com.android.support:support-core-utils:28.0.0"
}

In the android\app\build.gradle file,

Replace the version details

implementation 'com.android.support:appcompat-v7:26.1.0'

with

implementation 'com.android.support:appcompat-v7:+'

Android Studio will use a suitable version to make it work for you.


Today I have the similar problem.

Previous in my project gradle

// Top-level build file where you can add configuration options common to all 
sub-projects/modules.
allprojects {
repositories {
    jcenter()
    google()
    mavenCentral()
    maven { url "https://jitpack.io" }
    maven { url 'https://plugins.gradle.org/m2/'}
}}

Then I just added this below line in allprojects

maven {
        url "https://maven.google.com"
    }

It saved my day.

And now my current allproject {} code looks like this

allprojects {
repositories {
    jcenter()
    google()
    mavenCentral()
    maven { url "https://jitpack.io" }
    maven { url 'https://plugins.gradle.org/m2/'}
    maven {
        url "https://maven.google.com"
    }
}}

Just went to build.gradle and deleted the line:

implementation 'com.android.support:appcompat-v7:26.1.0'

After that, I re-synced the Gradle. Then, I pasted the line of code back, re-synced the Gradle again and it worked.

Note: While I was making this changes, I also updated all the SDK Tools that needed update.


Used implementation 'androidx.appcompat:appcompat:1.1.2' in App gradle fixed the issue for me


For other people where the accepted answer does not solve this issue...

As of September 2018, AndroidX has replaced the Android Support Libraries, which includes the appcompat-v7 library.

'com.android.support:appcompat-v7' becomes 'androidx.appcompat:appcompat:1.0.0'

'com.android.support:design' becomes 'com.google.android.material:material:1.0.0'

References:

https://developer.android.com/jetpack/androidx/migrate List of Support Libraries to AndroidX mappings


If you did not uncheck offline work, then make you sure you have internet for Android Studio to normalize your project.


Go to build.Gradle file and replace 27 and 29 by 25 at these places 1. targetSdkVersion 25 2. implementation 'com.android.support:appcompat-v7:25.+'

it really works for me Thanks.


This is a problem for users who live in a country that is banned by Google (like Iran). for this reason we need to remove these restrictions by a proxy. follow me :

file->settings->Appearance&Behavior->System Setting-> Http Proxy-> Manual proxy configuration ->HTTP -> Host name : fodev.org ->Port : 8118 .

and click Ok Button. then go to file-> Invalidate Caches/Restart . . . Use and enjoy the correct execution without error ;)


For users which have flavors in the project and found this thread:

Notice, that if your module dependency has different flavors, you should use one of the strategies:

  1. Module that tightens dependencies should have the same flavors and dimensions as the dependency module
  2. You should explicitly indicate which configuration you target in the module

Like that:

dependencies {
    compile project(path: ':module', configuration:'alphaDebug') 
}

Examples related to android

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? How to implement a simple scenario the OO way My eclipse won't open, i download the bundle pack it keeps saying error log getting " (1) no such column: _id10 " error java doesn't run if structure inside of onclick listener Cannot retrieve string(s) from preferences (settings) strange error in my Animation Drawable how to put image in a bundle and pass it to another activity FragmentActivity to Fragment A failure occurred while executing com.android.build.gradle.internal.tasks

Examples related to android-studio

A failure occurred while executing com.android.build.gradle.internal.tasks "Failed to install the following Android SDK packages as some licences have not been accepted" error Android Gradle 5.0 Update:Cause: org.jetbrains.plugins.gradle.tooling.util This version of Android Studio cannot open this project, please retry with Android Studio 3.4 or newer WARNING: API 'variant.getJavaCompile()' is obsolete and has been replaced with 'variant.getJavaCompileProvider()' Flutter plugin not installed error;. When running flutter doctor ADB.exe is obsolete and has serious performance problems Android design support library for API 28 (P) not working Flutter command not found How to find the path of Flutter SDK

Examples related to gradle

Gradle - Move a folder from ABC to XYZ A failure occurred while executing com.android.build.gradle.internal.tasks Gradle: Could not determine java version from '11.0.2' Android Gradle 5.0 Update:Cause: org.jetbrains.plugins.gradle.tooling.util Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0 Failed to resolve: com.android.support:appcompat-v7:28.0 Failed to resolve: com.google.firebase:firebase-core:16.0.1 com.google.android.gms:play-services-measurement-base is being requested by various other libraries java.lang.NoClassDefFoundError:failed resolution of :Lorg/apache/http/ProtocolVersion Error - Android resource linking failed (AAPT2 27.0.3 Daemon #0)

Examples related to android-gradle-plugin

WARNING: API 'variant.getJavaCompile()' is obsolete and has been replaced with 'variant.getJavaCompileProvider()' Android Material and appcompat Manifest merger failed Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve Failed to resolve: com.google.firebase:firebase-core:16.0.1 com.google.android.gms:play-services-measurement-base is being requested by various other libraries Invoke-customs are only supported starting with android 0 --min-api 26 error: resource android:attr/fontVariationSettings not found Exception : AAPT2 error: check logs for details Could not resolve com.android.support:appcompat-v7:26.1.0 in Android Studio new project Failed to resolve: com.android.support:appcompat-v7:27.+ (Dependency Error)