Gradle Build Error: Failed to complete:

I just downloaded Android Studio and created a new project and I get gradle build errors:

Failed to solve: com.android.support.test.espresso-core: 2.2.2

and

Failed to execute: com.android.support.appcompat-v7: 25.3.1

This error was resolved when reinstalling the SDK Tools + Repository + API when running android studio as an administrator.

I installed the API level 25 from which I want to build and download the Build-Tools SDK. I also already uploaded the support repository

Here is my application file:

apply plugin: 'com.android.application' android { compileSdkVersion 25 buildToolsVersion '25.0.3' defaultConfig { applicationId "com.jtsalas.mirrorcontrol" minSdkVersion 25 targetSdkVersion 25 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } compileOptions { sourceCompatibility JavaVersion.VERSION_1_6 targetCompatibility JavaVersion.VERSION_1_7 } productFlavors { } } dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) compile 'com.android.support:appcompat-v7:25.3.1' testCompile 'junit:junit:4.12' } 

build.gradle:

 // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.3.2' // 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 } 
+5
source share
5 answers

From the SDK manager, make sure you have installed and updated the Android and Google Repository support repository. Then you can find the corresponding artifacts in the subfolders of the / extras / android / m2repository directory

+3
source

From your mistake, it seems that you are not including the espresso libraries. The solution to this is to add the main espresso library, which is part of the Android testing support library hosted in the Google Maven repository, consider this a kind of git repository, but for dependencies.

So, we tell the gradle build system to look in the Maven repository for dependencies by specifying its URL.

This is done by adding the Maven URL to the build.gradle application level file in the repository block

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

and in the build.gradle file at the module level, specify the dependencies that you want from the maven repository, specifying their name as follows:

 dependencies{ //other dependencies go here //testing dependencies androidTestCompile 'com.android.support.test.espresso:espresso-core:3.0.1' } 

This is the reason for including the Maven repository URL in the application level build.gradle file, hope this helps.

+1
source

Well, I don’t know the perfect answer, but ..... how about comparing with my SDK Tools?

Imgur

0
source

I solved this by uninstalling Android Studios and uninstalling old versions of Android Studios in my C: \ Users [Username] and reinstalling Android Studio as an administrator.

0
source

It seems that you have updated Android studio and opened the previous project in it. The easiest way is to create a new project and copy 1. compileSdkVersion 26 2. buildToolsVersion "26.0.1" 3. targetSdkVersion 26 4. compile 'com.android.support:appcompat-v7:26.+' and paste them into the appropriate places on gradle application level. he will ask you to upgrade to take advantage. Let him upgrade. good luck ... It worked for me.

0
source

Source: https://habr.com/ru/post/1268151/


All Articles