Configuring Gradle for api 26 (Android)

Since I upgraded my Nexus 5x to Android O DP3, I cannot test my applications. I get an error because I have not configured my Gradle file to work with the new API level (26).

So, I changed this and the dependencies, but I keep getting errors in all my support libraries, such as

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

By clicking

 Install repository and sync project 

Restores the progress of the dialog to load the correct dependency, but does not remove the error. Cleaning up the project, installing repositories, and then restoring the project will also not work.

Appcompat-v7

In appcompat-v7: 26.0.0-beta2 I get (before even Gradle sync) squeaky lines with an 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 set up the Gradle file for Android API 26 correctly? Any help would be appreciated.

PS: I am using Gradle 3.0.0-alpha3 at the moment, but getting 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' } 
+59
android build.gradle gradle android-o android-support-library android-8.0-oreo
Jun 12 '17 at 13:02 on
source share
7 answers

Have you added google maven endpoint ?

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

Add the endpoint to the build.gradle file:

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

What can be replaced by google() shortcut with Android Gradle v3:

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

If you already have a maven url inside repositories , you can add a link after them, i.e.:

 allprojects { repositories { jcenter() maven { url 'https://jitpack.io' } maven { url 'https://maven.google.com' } } } 
+130
Jun 12 '17 at 15:48
source share
 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' 
+13
Aug 25 '17 at 4:53 on
source share

Appart from setting the maven source url to your gradle, I would suggest adding design libraries and appcompat. 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' 
+8
Sep 17 '17 at 16:11
source share

You can add google() to the repository block

 allprojects { repositories { jcenter() maven { url 'https://github.com/uPhyca/stetho-realm/raw/master/maven-repo' } maven { url "https://jitpack.io" } google() } } 
+7
Jul 01 '17 at 17:00
source share

A solution appears permitted by Android Studio 3.0 Canary 4 and Gradle 3.0.0-alpha4.

+6
Jun 16 '17 at 19:02
source share

you should add build.gradle to your MODULE-LEVEL file:

 //module-level build.gradle file repositories { maven { url 'https://maven.google.com' } } 

see Google Maven Repository

I noticed that when I use Android Studio 2.3.3, I MUST add the {maven {url ' https://maven.google.com '}} repositories to MODULE-LEVEL build.gradle. In the case of Android Studio 3.0.0, there is no need to add build.gradle to the module. Just add to the project level build.gradle, which was mentioned in other posts here, namely:

 //project-level build.gradle file allprojects { repositories { jcenter() maven { url 'https://maven.google.com/' name 'Google' } } } 

UPDATE 11-14-2017: The solution I submit was valid when I made the message. Since then there have been various updates (even regarding the site to which I link), and I do not know if this is true. For one month, I did my work depending on the solution above, until I switched to Android Studio 3.0.0

+5
Sep 28 '17 at 11:13 on
source share

after adding:

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

make sure your Gradle sync is online

You can check this in: Android studio -> Settings -> Build, Run, Deploy -> Gradle -> Offline (make sure this box is not checked)

0
Jul 14 '19 at 20:05
source share



All Articles