Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failed to resolve: com.android.support:appcompat-v7:26.0.0

I am having this issue in Android studio.

Error:(22, 13) Failed to resolve: com.android.support:appcompat-v7:26.0.0 <a href="install.m2.repo">Install Repository and sync project</a><br><a href="openFile:C:/Users/username/AndroidStudioProjects/ElectroSave/app/build.gradle">Show in File</a><br><a href="open.dependency.in.project.structure">Show in Project Structure dialog</a> 

This is my Gradle code:

apply plugin: 'com.android.application'  android {        compileSdkVersion 26       buildToolsVersion "25.0.2"     defaultConfig {     applicationId "com.example.noelly.myapplication"     minSdkVersion 19     targetSdkVersion 25     versionCode 1     versionName "1.0" }    buildTypes {       release {         minifyEnabled false         proguardFiles getDefaultProguardFile('proguard-android.txt'),  'proguard-rules.pro'      dependencies {      compile fileTree(dir: 'libs', include: ['*.jar'])      compile 'com.android.support:appcompat-v7:26.0.0' } 
like image 968
CyberCat Avatar asked Jul 27 '17 17:07

CyberCat


2 Answers

To use support libraries starting from version 26.0.0 you need to add Google's Maven repository to your project's build.gradle file as described here: https://developer.android.com/topic/libraries/support-library/setup.html

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

For Android Studio 3.0.0 and above:

allprojects {         repositories {             jcenter()             google()         }     } 
like image 184
Dangiras Rackauskas Avatar answered Oct 04 '22 17:10

Dangiras Rackauskas


Please be noted, we need to add google maven to use support library starting from revision 25.4.0. As in the release note says:

Important: The support libraries are now available through Google's Maven repository. You do not need to download the support repository from the SDK Manager. For more information, see Support Library Setup.

Read more at Support Library Setup.

Play services and Firebase dependencies since version 11.2.0 are also need google maven. Read Some Updates to Apps Using Google Play services and Google APIs Android August 2017 - version 11.2.0 Release note.

So you need to add the google maven to your root build.gradle like this:

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

For Gradle build tools plugin version 3.0.0, you can use google() repository (more at Migrate to Android Plugin for Gradle 3.0.0):

allprojects {     repositories {         jcenter()         google()     } } 

UPDATE:

From Google's Maven repository:

The most recent versions of the following Android libraries are available from Google's Maven repository:

  • Android Support Library
  • Architecture Components Library
  • Constraint Layout Library
  • Android Test Support Library
  • Databinding Library
  • Android Instant App Library
  • Google Play services
  • Firebase

To add them to your build, you need to first include Google's Maven repository in your top-level / root build.gradle file:

allprojects {     repositories {         google()          // If you're using a version of Gradle lower than 4.1, you must instead use:         // maven {         //     url 'https://maven.google.com'         // }         // An alternative URL is 'https://dl.google.com/dl/android/maven2/'     } } 

Then add the desired library to your module's dependencies block. For example, the appcompat library looks like this:

dependencies {     compile 'com.android.support:appcompat-v7:26.1.0' } 

However, if you're trying to use an older version of the above libraries and your dependency fails, then it's not available in the Maven repository and you must instead get the library from the offline repository.

like image 24
ישו אוהב אותך Avatar answered Oct 04 '22 19:10

ישו אוהב אותך