Setting up Gradle for api 26 (Android)

109,307

Solution 1

Have you added the google maven endpoint?

Important: The support libraries are now available through Google's Maven repository. You do not need to download the support repository from the SDK Manager. For more information, see Support Library Setup.

Add the endpoint to your build.gradle file:

allprojects {
    repositories {
        jcenter()
        maven {
            url 'https://maven.google.com'
        }
    }
}

Which can be replaced by the shortcut google() since Android Gradle v3:

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

If you already have any maven url inside repositories, you can add the reference after them, i.e.:

allprojects {
    repositories {
        jcenter()
        maven {
            url 'https://jitpack.io'
        }
        maven {
            url 'https://maven.google.com'
        }
    }
}

Solution 2

allprojects {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
}

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.1"
    defaultConfig {
        applicationId "com.keshav.retroft2arrayinsidearrayexamplekeshav"
        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'
        }
    }
}
 compile 'com.android.support:appcompat-v7:26.0.1'
    compile 'com.android.support:recyclerview-v7:26.0.1'
    compile 'com.android.support:cardview-v7:26.0.1'

Solution 3

Appart from setting maven source url to your gradle, I would suggest to add both design and appcompat libraries. Currently the latest version is 26.1.0

maven {
    url "https://maven.google.com"
}

...

compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:design:26.1.0'

Solution 4

You could add google() to repositories block

allprojects {
    repositories {
        jcenter()
        maven {
            url 'https://github.com/uPhyca/stetho-realm/raw/master/maven-repo'

        }
        maven {
            url "https://jitpack.io"
        }
        google()
    }
}

Solution 5

Appears to be resolved by Android Studio 3.0 Canary 4 and Gradle 3.0.0-alpha4.

Share:
109,307
GunnarK
Author by

GunnarK

Updated on July 08, 2022

Comments

  • GunnarK
    GunnarK about 2 years

    Since I have upgraded my Nexus 5x to Android O DP3 I am not able to test my applications. I get the error for not having configured my Gradle-file to work with the new API-level (26).

    So I changed this and the dependencies, but I keep getting errors on ALL my support libraries like

    Failed to resolve: com.android.support:design:26.0.0-beta2
    

    Clicking on

    Install repository and sync project
    

    Pops up a progressdialog for downloading the right dependency but does not remove the error. Cleaning up project, installing repositories and then rebuilding the project won't work either.

    appcompat-v7

    On appcompat-v7:26.0.0-beta2 I get (before even a Gradle sync) squickly lines with the error:

    When using a compileSdkVersion older than android-O revision 2,
    the support library version must be 26.0.0-alpha1 or lower (was 26.0.0-beta2)
    

    Can someone help me get the gradle file to be configured correctly for Android API 26? Any help would be appreciated.

    PS: I'm using Gradle 3.0.0-alpha3 at the moment but get the same error on Gradle 2.3.2

    My Gradle file:

    apply plugin: 'com.android.application'
    
    android {
    compileSdkVersion 26
    buildToolsVersion '26.0.0'
    
    defaultConfig {
        applicationId "********"
        minSdkVersion 21
        targetSdkVersion 26
        versionCode 3
        versionName "2.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    }
    
    dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:26.0.0-beta2'
    compile 'com.android.support:design:26.0.0-beta2'
    compile 'com.github.bumptech.glide:glide:3.7.0'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.android.support:cardview-v7:26.0.0-beta2'
    compile 'com.android.support:recyclerview-v7:26.0.0-beta2'
    compile 'com.redbooth:WelcomeCoordinator:1.0.1'
    compile 'com.github.kittinunf.fuel:fuel-android:1.4.0'
    compile 'com.pkmmte.view:circularimageview:1.1'
    compile 'com.ramotion.foldingcell:folding-cell:1.1.0'
    }