0

I upgrade my android studio form version 2.3.3 to version 3.1.3. But now, When I create a new project for the first time this error occurred:

Unable to resolve dependency

This is my build.gradle(Project:):

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

buildscript {

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


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

Also this file is build.gradle(Module:app):

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "giant.shoot.ir.glinter.myapplication"
        minSdkVersion 18
        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.1.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}

What is the problem?

Saeed
  • 3,294
  • 5
  • 35
  • 52
  • Try to do a "Clean Project" and try to "Make Project" again – Hamlet Leon Aug 02 '18 at 13:31
  • I do this, but this error comming: Could not GET 'https://jcenter.bintray.com/com/android/support/appcompat-v7/26.1.0/appcompat-v7-26.1.0.pom'. – Saeed Aug 02 '18 at 13:40

1 Answers1

0

You are missing the debug buildType in your build.gradle(Module:app) file.

Change this

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

to this

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

Relevant Stack Overflow post for more information.

EDIT: Include this in your build.gradle(Project:) file

buildscript {
   ...
   repositories {
        mavenCentral()
        maven { url "https://maven.fabric.io/public" }
        google()
        jcenter()
    }
    ...
}

allprojects {
    repositories {
        mavenCentral()
        maven { url "https://maven.fabric.io/public" }
        google()
        jcenter()
    }
}