1

I am tired to sort out this error in android studio. I literally wasted my precious time of 2 days to solve this such a stupid error. Guys please try to help me out from this situation. T don't think that I left any link on SO which I have not tried. But no Luck.

I am using android studio 2.3.3

My root level gradle file as follows:-

    buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.3'
        classpath 'com.google.gms:google-services:3.0.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
        maven { url "https://jitpack.io" }
    }
}

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

My app build as follows:-

  apply plugin: 'com.android.application'
    android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "com.myAppId"
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

    repositories {
    mavenCentral()
}

    dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.2.0'
    compile 'com.android.support:recyclerview-v7:25.2.+'
    compile 'com.android.support:design:25.2.0'
    compile 'com.google.code.gson:gson:2.6.2'
    compile 'com.squareup.retrofit2:retrofit:2.0.2'
    compile 'com.facebook.android:facebook-android-sdk:[4,5)'
    compile 'com.squareup.retrofit2:converter-gson:2.0.2'
    compile 'com.squareup.retrofit2:converter-scalars:2.3.0'
    compile 'com.google.android.gms:play-services-location:9.2.1'
    compile 'com.github.bumptech.glide:glide:3.7.0'
    compile 'com.google.android.gms:play-services-auth:9.2.1'
    testCompile 'junit:junit:4.12'
    compile files('libs/ormlite-android-4.43.jar')
    compile files('libs/ormlite-core-4.43.jar')
    compile files('libs/universal-image-loader-1.9.5.jar')
    compile 'com.nineoldandroids:library:2.4.0'
    compile 'com.daimajia.androidanimations:library:1.0.3@aar'
    compile 'in.srain.cube:grid-view-with-header-footer:1.0.12'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.android.support:palette-v7:25.2.0'
    compile 'com.github.jd-alexander:LikeButton:0.2.1'
    compile 'com.github.techery:properratingbar:0.0.5'
    compile 'com.github.GoodieBag:Pinview:v1.3'
    compile project(':library')
}
apply plugin: 'com.google.gms.google-services'

My gradle-wrapper.properties:-

 distributionBase=GRADLE_USER_HOME
 distributionPath=wrapper/dists
 zipStoreBase=GRADLE_USER_HOME
 zipStorePath=wrapper/dists
 distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip

I am using build tools version as 25.0.2. I don't know why it is giving me error of 27.0.2.

Following errors I am facing:-

Error in AS

Umair
  • 6,366
  • 15
  • 42
  • 50
Deepak Sharma
  • 4,999
  • 5
  • 51
  • 61
  • 1
    If there is a library using 27.0.2, It will give you the error. – Cao Minh Vu Mar 29 '18 at 10:39
  • 1
    The problem is you are not using latest android versions and build tools, but some of your libraries are doing so. So that's why you can't sync your gradle files. Either you remove those libraries or update your gradle to latest versions of android – Umair Mar 29 '18 at 10:41
  • 1
    1. Avoid using + sign in gradle dependency Use compile 'com.android.support:recyclerview-v7:25.2.0' instead of compile 'com.android.support:recyclerview-v7:25.2.+' 2. Update your gradle version and android studio. – chetan prajapat Mar 29 '18 at 10:42

4 Answers4

2

Got the solution. Just Replace

compile 'com.facebook.android:facebook-android-sdk:[4,5)'

by

compile 'com.facebook.android:facebook-android-sdk:4.26.0'
Deepak Sharma
  • 4,999
  • 5
  • 51
  • 61
0

Please try to replace compile to implementation. Such as

compile 'com.android.support:appcompat-v7:25.2.0'
compile 'com.android.support:recyclerview-v7:25.2.+'

to

 implementation 'com.android.support:appcompat-v7:25.2.0'
 implementation 'com.android.support:recyclerview-v7:25.2.+'

Hope this will help.

For more update you can go through this: What's the difference between implementation and compile in gradle

Faysal Ahmed
  • 7,501
  • 5
  • 28
  • 50
0

Failed to resolve: com.android.support:appcompat-v7:27.0.2

Add the google() repository to both repositories closures in your project-level build.gradle file.

Actually, since you are on an old version of the tools, that will need to be this instead of google():

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

I don't know why it is giving me error of 27.0.2.

One or more of your dependencies are asking for 27.0.2. For example, compile 'com.facebook.android:facebook-android-sdk:[4,5)' will give you an indeterminate version of that library, and that version might be asking for 27.0.2 of the Support Library.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
0

I think your android studio Gradle settings "Offline work" is enabled you need to disable this setting and it will work fine.

To do that : 1. Android studio preference->Build, Execution,Deployment->Gradle 2.Uncheck Offline work

banty
  • 1,019
  • 1
  • 8
  • 9