Today I updated android studio to version 3.0
And after that I couldn't build project successfully.
I got these errors:
Unable to resolve dependency for ':app@release/compileClasspath': could not resolve com.android.support:appcompat-v7:27.0.1.
I tried using VPN or proxy etc. but none of them worked.
It's been a long day. I hope you may help me.
This is my build.gradle(app) :
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 27
defaultConfig {
applicationId "ir.hetbo.kotlin_tutorial"
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'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:27.0.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
}
and this is build.gradle(project):
// Top-level build file where you can add configuration options common to
all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.1.60'
repositories {
google()
jcenter()
maven {
url "https://maven.google.com"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven {
url "https://maven.google.com"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I did a lot of things to fix it but every time it failed.
I use gradle 4.3.1
And here is gradle wrapper properties :
#Sat Nov 18 10:16:45 IRST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.3.1-all.zip
There is one build.gradle file for whole projects and one for each modules. Need to add below code in the application build.gradle file.
As of the new versions, the libraries are now inside the
maven
not insideJcenter
.So inside your gradle file, you have to add
maven
like the below:This link may help you: Adding support libraries
with the new features of gradle 4.1 and the classpath 'com.android.tools.build:gradle:3.0.0'
and and this is build.gradle(project):
Try this code in build.gradle(Project) :