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

Ugur Konak picture Ugur Konak · Sep 27, 2018 · Viewed 8.9k times · Source

I am using android studio 3.2 and I installed android studio 2.2 before using this one. When I open a new project I get these errors I mentioned below. I want to mention again that I didn't make any change on layouts or main.activity. I have checked the solutions for old versions but the problem still exist. Here is what I have tried before:

changing apply plugin: 'com.android.application' to apply plugin: 'com.android.library' - Unchecking offline mode. - Adding repositories :

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

- changing appcompat to older versions (v7:26+ or v7:25) Here are the logs of the errors :

Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support.constraint:constraint-layout:1.0.1.
Open File
Show Details


Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.android.support.test:runner:1.0.2.
Open File
Show Details


Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.android.support.test.espresso:espresso-core:3.0.2.
Open File
Show Details


Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.android.support.constraint:constraint-layout:1.0.1.
Open File
Show Details


Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.android.support.constraint:constraint-layout:1.0.1.
Open File
Show Details


Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve junit:junit:4.12.
Open File
Show Details


Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve com.android.support.constraint:constraint-layout:1.0.1.
Open File
Show Details


Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve com.android.support.constraint:constraint-layout:1.0.1.
Open File
Show Details


Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve junit:junit:4.12.
Open File
Show Details

--> My gradle.wrapper.properties

#Thu Sep 27 09:39:31 EET 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists zipStoreBase\=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-all.zip

--> My build.gradle(app)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    buildToolsVersion "28.0.3"
    defaultConfig {
        applicationId "com.example.a26033623.myapplication"
        minSdkVersion 15
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }

    }
    productFlavors {
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

--> build.gradle(project)

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

buildscript {

    repositories {
        google()
        jcenter()
        mavenCentral()
        maven {
            url "https://maven.google.com"
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.0'


        // 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
}

I am truly struggling for 2 days browsing the solutions, and I really feel lost. Thanks for your time, attention and your help in advance.

Answer

Aniruddh Parihar picture Aniruddh Parihar · Sep 27, 2018

Try this way

1) Android Studio 3.1.4

2)

COMPILE_SDK_VERSION=26
BUILD_TOOLS_VERSION=27.0.3
TARGET_SDK_VERSION=26

3)

build.gradle{project}

buildscript {
    repositories {
        jcenter()
        google()
        mavenCentral()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.4'

    }
}

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

}

4) support library version should be same you can use 26.1.0 for above configuration, for Example com.android.support:appcompat-v7:26.1.0

5) and final step is

gradle-wrapper.properties

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip