2

I have installed Android Studio 3 in my system and assigned a API level 26 version 1 & 2 both (Android Oreo (8.0) to the project as shown in the image below:

SDK Platform installed image

And the SDK tools as 26.1.1 version installed as shown in image below:

SDk tools

Code in app module gradle:

version reference in gradle

Troubleshooting steps i have tried so far:

  1. changing the versions of appcompact-v7 in gradle file to (26.0.0,26.0.1,26.0.2,26.1.1,26.1.2) and sync.
  2. Invalidate cache and restart.
  3. Rebuild project.

I did not get success in above methods. I get the error messages as:

error message

and in more details according to the respective versions I get error msg as:

more error details

But if I change the version as appcompact-v7:+ then it works fine and gradle sync is successful. I know that it is not a good practice to use the above method.

How can we resolve the above error. Or is there any way we can find out which version of appcompact the studio is downloading when we add reference as appcompact-v7:+ ?

I am new to Android Studio and Android development.

halfer
  • 19,824
  • 17
  • 99
  • 186

3 Answers3

1

Since API 26, Google has moved the repository to Google() repo. You must add it in your build.gradle project file:

buildscript {
    repositories {
        mavenCentral()
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

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

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

and don't forget to update your gradle wrapper. You can use this command:

>gradle wrapper --gradle-version 4.2
Fakher
  • 2,098
  • 3
  • 29
  • 45
0

Check ur build files. This is the best way to do it.

In your root level gradle.build use below

buildscript {
    repositories {
        mavenCentral()
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

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

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

and in your gradle-wrapper.properties file change the wrapper version as below

distributionUrl=https\://services.gradle.org/distributions/gradle-4.3-all.zip

also in your app level build.gradle make sure you are using 26 vesion as below

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.2"
    defaultConfig {
        applicationId "com.xxxx"
        minSdkVersion 16
        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'
        }
    }
}
Niraj Sanghani
  • 1,493
  • 15
  • 23
0

(Sry it would be better as a comment, but I can't)

If you are behind a proxy check your gradle.properties with proxy configuration

systemProp.http.proxyHost=[url/ip]
systemProp.http.proxyPort=[port]
systemProp.https.proxyHost=[url/ip]
systemProp.https.proxyPort=[port]
Hochmah
  • 1
  • 1