0

I'm getting these errors:

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

Error:Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.android.support.test:runner:1.0.1.

Error:Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.android.support.test.espresso:espresso-core:3.0.1.

Error:Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.android.support.test.espresso:espresso-core:3.0.1.

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

Error:Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve junit:junit:4.12.

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

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

Error:Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve junit:junit:4.12.

Application build.gradle file (project:MyApplication)

buildscript {

repositories {
    google()
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.0.1'


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

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

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

Application build.gradle file (Module:app)

apply plugin: 'com.android.application'

android {
compileSdkVersion 26
defaultConfig {
    applicationId "com.example.hp_pc.myapplication"
    minSdkVersion 15
    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 {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-
core:3.0.1'
}
Android Geek
  • 8,956
  • 2
  • 21
  • 35
SriDatta Yalla
  • 766
  • 8
  • 13

3 Answers3

0

Try this,

Go to your

gradle.properties

write the below code and Sync your project

android.enableAapt2=false
Community
  • 1
  • 1
Android Geek
  • 8,956
  • 2
  • 21
  • 35
  • Try adding this -- in your gradle(Project) --> allprojects { repositories { google() jcenter() mavenCentral() maven { url "https://maven.google.com" } } } – Android Geek Nov 28 '17 at 06:13
0

You have to try like this

  1. Delete your build folder in your project root directory
  2. Delete your build folder inside of your project app folder

this both are cache some intermediate files and some debug-gable file so only its happening...

after delete this both folders then rebuild your project it will work properly.

follow this steps

enter image description here

your project root directory looking like that, here delete this highlighted build folder, then go to inside your app folder in this same window

inside app folder have one more build folder its also delete

then rebuild your project.

Raja
  • 2,775
  • 2
  • 19
  • 31
0

Here i tried your gradle, here it is:

Project level gradle

App Level gradle

Updated Android Studio

what you are getting errors is not getting here.

My solution is:

  1. Try to clear your project.
  2. Go to AndroidStudio > File > Invalidate/Restart, it will help.
  3. If nothing works then delete this project create new one.
Yevhen Dubinin
  • 4,657
  • 3
  • 34
  • 57
Ankit Patidar
  • 2,731
  • 1
  • 14
  • 22