46

I have just created a new Android Studio project for both Android Mobile and wear. The initial gradle build failed because I am getting several errors-

Error: Failed to resolve: com.android.support:support-v4:26.0.0

Error: Failed to resolve: com.android.support:percent:26.0.0

Error: Failed to resolve: com.android.support:recyclerview-v7:26.0.0

Error: Failed to resolve: com.android.support:support-annotations:26.0.0

With each error, I am given the option to Install repository and sync project, but nothing happens when I click on it. I have spent several hours trying to find why I am getting these errors, but I can't find any solutions. Does anybody know how to fix these very frustrating errors? Thank you!

build.gradle (project)

// Top-level build file where you can add configuration options common to all sub-projects/modules.

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

    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'

        // NOTE: Do not place your application dependencies here; they   belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

build.gradle (mobile)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.1"
    defaultConfig {
        applicationId "com.georgeberdovskiy.androidweartest"
        minSdkVersion 23
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-   core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    wearApp project(':wear')
    compile 'com.google.android.gms:play-services-wearable:11.0.4'
    compile 'com.android.support:appcompat-v7:26+'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile "com.android.support:support-core-utils:26+"
    testCompile 'junit:junit:4.12'
}

build.gradle (wear)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.1"
    defaultConfig {
        applicationId "com.georgeberdovskiy.androidweartest"
        minSdkVersion 23
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    provided 'com.google.android.wearable:wearable:2.0.4'
    compile 'com.google.android.support:wearable:2.0.4'
    compile 'com.google.android.gms:play-services-wearable:11.0.4'
    compile "com.android.support:support-core-utils:26+"
}

I am sure that my version of Android Studio is updated, and all support repositories and APIs are installed. enter image description here

Community
  • 1
  • 1
George B
  • 918
  • 3
  • 15
  • 24
  • I am noticing that these errors are only for the wear build.gradle... – George B Jul 29 '17 at 05:04
  • 1) change your buildToolsVersion "26.0.1" into buildToolsVersion "26.0.0" 2) change dependencies version from compile 'com.android.support:recyclerview-v7:26.0.0' into compile 'com.android.support:recyclerview-v7:26.0.0-alpha1' Hope this helps you. – Madhan Jul 29 '17 at 07:56
  • changing build version will work, let me know if you find any difficulties on that – Madhan Jul 29 '17 at 10:04
  • For IONIC 3 check solution here --> https://www.freakyjolly.com/ionic-3-resolve-execution-failed-for-task-appprocessdebugresources/ – Code Spy Nov 03 '18 at 09:26

10 Answers10

78

I don't have an Android wear project, but I had the same problem when I wanted to upgrade the Support Library version for an existing project to 26.0.0. Since 26.0.0 the support libraries are available through Google's Maven repository. So I had to add the repository to my build. gradle file.

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

Check out https://developer.android.com/topic/libraries/support-library/setup.html for more details.

Kevin
  • 1,506
  • 9
  • 12
11

The following worked for me:

In the Application build.gradle considered to add following:

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

in the Module build.gradle:

compileSdkVersion 26
buildToolsVersion "26.0.1"

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.google.android.gms:play-services-wearable:11.0.4'
compile 'com.android.support:support-compat:26.0.1'
compile 'com.android.support:support-v4:26.0.1'
compile 'com.google.android.gms:play-services:11.0.4'
compile 'com.android.support:appcompat-v7:26.0.1'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:support-annotations:26.0.1'
compile 'com.android.support:support-vector-drawable:26.0.1'
compile 'com.android.support:animated-vector-drawable:26.0.1'
compile 'com.android.support:design:26.0.1'
compile 'com.android.support:support-v13:26.0.1'
compile 'com.android.support:percent:26.0.1'
compile 'com.android.support:wear:26.0.1'
compile 'com.google.android.support:wearable:2.0.4'
provided 'com.google.android.wearable:wearable:2.0.4'
}
  • finally I updated the depencies w IMPLEMETATION instead of COMPILE. I am still not able to split gms:play-services:11.6.2 into single modules, I need. It leads me into a disaster by destroing everything, I am fighting for a fifth night w that, finally giving up and loading the whole package. – Parkbrakereminder Dec 19 '17 at 00:09
  • Try com.android.support version should same. – Khurshid Ansari Jan 19 '20 at 04:56
5

Either change your build tool version from 26.0.1 to 26.0.0 or you can replace 26.0.0 by 26.+ like below.

compile 'com.android.support:support-v4:26.0.0'

to

compile 'com.android.support:support-v4:26.+"

Do same with all... Hope it helps. Happy Coding! ^_^

Arjun Katwal
  • 247
  • 1
  • 3
  • 11
3

Replace this:

    compile 'com.android.support:recyclerview-v7:26.0.0'

With this

    compile 'com.android.support:recyclerview-v7:26.0.0-alpha1'

Do same with all

Update - new version released

    compile 'com.android.support:recyclerview-v7:26.1.0'
Hamid Reza
  • 624
  • 7
  • 23
3

For now, I fixed this with changing in the wear build.gradle:

compile 'com.google.android.support:wearable:2.0.3'
provided 'com.google.android.wearable:wearable:2.0.3'

It seems like the problem is com.google.android.support:wearable:2.0.4. With that, Using 26.0.1 build tools compiles fine. I haven't gone any further with this but it looks like a dependency problem related to a repository although that is really just a guess from the error messages.

John Smith
  • 3,493
  • 3
  • 25
  • 52
3

Add the following dependencies in your app/build.gradle.

repositories {
    maven { url 'https://maven.fabric.io/public' }
    maven{url 'https://maven.google.com'}
}
Satan Pandeya
  • 3,747
  • 4
  • 27
  • 53
Thunderstick
  • 1,193
  • 13
  • 12
2

Add following dependency in your gradle

Replace

    compile 'com.android.support:support-v4:26.0.0'

with

   compile 'com.android.support:support-v4:25.0.0'

and Replace

   compile 'com.android.support:appcompat-v7:26+'

with

compile 'com.android.support:appcompat-v7:25.0.0'
Anil
  • 1,087
  • 1
  • 11
  • 24
  • 1
    Didn't work, now I get another error on top of the other ones - `Error:(30, 13) Failed to resolve: com.android.support:support-v4:26.0.0` – George B Jul 29 '17 at 04:37
1

The reason that my project was giving me these errors was because I created the project for Android Platform 26. However, Wear currently doesn't support 26, and it is essential to change the target and compile SDK versions to 25 in the wear module of build.gradle.

Link to Android Developers documentation - https://developer.android.com/training/wearables/apps/creating.html#setting-up-a-phone

build.gradle (wear)

apply plugin: 'com.android.application'


android {
compileSdkVersion 25
buildToolsVersion "26.0.1"

defaultConfig {
    applicationId "com.georgeberdovskiy.findmyphone"
    minSdkVersion 25
    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.google.android.support:wearable:2.0.3'
provided 'com.google.android.wearable:wearable:2.0.3'
compile 'com.google.android.gms:play-services-maps:11.0.4'
compile 'com.google.firebase:firebase-core:11.0.4'
compile 'com.google.firebase:firebase-database:11.0.4'
compile 'com.google.android.gms:play-services-wearable:11.0.4'

}

apply plugin: 'com.google.gms.google-services'

I only needed to change the compile and target SDK versions to 25 in the wear module. I left them as 26 for the mobile module.

George B
  • 918
  • 3
  • 15
  • 24
  • 1
    You should make sure to use a buildToolVersion with the same major version number as the compileSdkVersion (in this case 25.X.X) for best result. – TofferJ Jul 31 '17 at 17:27
  • Using build tools 26.0.1 works very well for me. Thank you for the suggestion though. – George B Jul 31 '17 at 19:13
1

This one worked for me

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

google() does the magic with the following configuration

Studio version : 3.0 beta 2

classpath 'com.android.tools.build:gradle:3.0.0-beta2'

distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-rc-1-all.zip
HSpector
  • 11
  • 2
0

I meet this problem, changing the build tool/ sdk version didn't work, clearly write compile version didn't work, off line build didn't work.

Finally I just change wearable version, and this problem gone.

provided 'com.google.android.wearable:wearable:2.0.4'
compile 'com.google.android.support:wearable:2.0.4'

to

provided 'com.google.android.wearable:wearable:2.0.2'
compile 'com.google.android.support:wearable:2.0.2'

By the way, I used offline building now because it is really fast when I check this issue.

Satan Pandeya
  • 3,747
  • 4
  • 27
  • 53
FL.S
  • 23
  • 3