Gradle change failed

This is my first time trying to use gradle with an android project. I would like to add a modification to my project, but he continues to tell me.

Failed to execute: com.squareup.retrofit: retrofit: 1.9.0

Failed to execute: com.squareup.okhttp: 2.2.0

However, Google Play services work great.

My gradle file looks like this:

apply plugin: 'com.android.application' android { compileSdkVersion 21 buildToolsVersion "21.1.2" defaultConfig { applicationId "test.gradel" minSdkVersion 14 targetSdkVersion 21 versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') compile 'com.android.support:appcompat-v7:21.0.3' compile 'com.google.android.gms:play-services:6.5.87' compile group: "com.squareup.retrofit", name: "retrofit", version: "1.9.0" compile group: "com.squareup.okhttp", name: "okhttp", version: "2.2.0" } buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:1.1.2' } } 

Any help would be greatly appreciated.

thanks

+5
source share
2 answers

The problem was fixed by creating a higher level build.gradle file and moving the following code into it.

 buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:1.1.2' } } allprojects { repositories { jcenter() } } 
+2
source

You must indicate where you can find these artifacts. You need to add the repository block to the script.

You must add this to your build.gradle

  repositories { mavenCentral() } 

or

  repositories { jcenter() } 

The Google services library works because it is located in the Google repository, which is downloaded using the SDK manager.

+1
source

Source: https://habr.com/ru/post/1214421/


All Articles