13

I have a problem with gradle. it was working fine but all of sudden when I was rebuilding the project it gives me this error:

Error:Failed to resolve: support-vector-drawable

I can't find out what my problem is?

My app.gradle

buildscript {
    repositories {
        maven { url 'https://plugins.gradle.org/m2/' }
    }
    dependencies {
        classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.8.1'
    }
}

apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'

repositories {
    maven { url 'https://maven.google.com' }
}

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

android {
    compileSdkVersion 26
    buildToolsVersion '26.0.2'
    defaultConfig {
    applicationId "com.arizeh.arizeh"
    minSdkVersion 17
    targetSdkVersion 22
    multiDexEnabled true
    versionCode 29
    versionName "3.0.5"
    useLibrary 'org.apache.http.legacy'
    testInstrumentationRunner 
    buildTypes {
        release {
           minifyEnabled false
           proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility 1.8
        targetCompatibility 1.8
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    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:26+'
    testCompile 'junit:junit:4.12'
    compile 'com.google.android.gms:play-services-maps:15.0.1'
    compile 'com.google.android.gms:play-services-places:15.0.1'
    compile 'com.google.android.gms:play-services-location:15.0.1'
    compile 'com.google.android.gms:play-services-gcm:15.0.1'
    compile 'com.google.android.gms:play-services-base:15.0.1'
    compile 'com.google.firebase:firebase-messaging:15.0.2'

    compile 'com.android.support:design:26.1.0'
    compile 'com.android.support:cardview-v7:26.1.0'
    compile 'uk.co.chrisjenx:calligraphy:2.1.0'
    compile 'com.google.code.gson:gson:2.8.0'
    compile 'com.koushikdutta.ion:ion:2.+'
    compile 'com.android.support:percent:26.1.0'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.shawnlin:number-picker:2.4.2'
    compile 'com.astuetz:pagerslidingtabstrip:1.0.1'
    compile 'com.android.support:multidex:1.0.2'
    compile 'com.android.support:support-compat:26.1.0'
    compile 'com.daimajia.easing:library:2.0@aar'
    compile 'com.daimajia.androidanimations:library:2.2@aar'

    compile 'com.zarinpal:purchase:0.0.3-beta'

    compile 'com.squareup.retrofit2:retrofit:2.3.0'
    compile 'com.squareup.retrofit2:converter-gson:2.3.0'
} 
Zoe
  • 27,060
  • 21
  • 118
  • 148
amirhesni
  • 441
  • 1
  • 6
  • 22

9 Answers9

34

In my case, I've moved the Google repo on the top in the build.gradle config:

allprojects {
  repositories {
      google() // now here
      mavenLocal()
      jcenter()
      maven {
          // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
        url "$rootDir/../node_modules/react-native/android"
      }
      // google() // was here
  }
}
Vladimir Vlasov
  • 1,860
  • 3
  • 25
  • 38
19

Add vectorDrawables.useSupportLibrary = true in defaultConfig

defaultConfig {
    vectorDrawables.useSupportLibrary = true
}

If an error still persists then

allprojects {
 repositories {
    google() // make it first element
    jcenter()
    maven { url 'https://maven.google.com' }
    }
  }
Jarvis
  • 1,714
  • 2
  • 20
  • 35
9

I just encountered this error along with some others:

Failed to resolve: support-vector-drawable
Failed to resolve: livedata-core
Failed to resolve: common
Failed to resolve: runtime
Failed to resolve: viewmodel
Failed to resolve: monitor

I'm not using React Native but found the answer on there:

In android/build.gradle move the jcenter() to the bottom:

allprojects {
    repositories {
        google()
        maven {
            url 'https://maven.google.com/'
        }
        jcenter()
    }
}
Leon
  • 3,614
  • 1
  • 33
  • 46
  • 1
    ooh WOOOW WTF is wrong with android development? I can't just spend 8 hours on debugging gradle scripts on every android update -_- – Tudor Oct 28 '18 at 21:26
  • @Tudor Yep, I am iOS mainly and coming back to Android is such a PITA. – Leon Oct 29 '18 at 13:42
8

I faced this error on androidx project and solved it with:

1- in Build.gradle (Module file), android{} section add:

   vectorDrawables.useSupportLibrary = true

2- in dependencies {} section,

change :

 implementation 'androidx.vectordrawable:vectordrawable:1.0.1'

to update version:

 implementation 'androidx.vectordrawable:vectordrawable:1.1.0-beta02'

compile again.

Hamed Jaliliani
  • 2,789
  • 24
  • 31
7

I had the same problem. you must change build.gradle to

 // Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        google()
        jcenter()
        mavenCentral()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.0'

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

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

    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
abolfazl bazghandi
  • 935
  • 15
  • 29
4

I had the same problem. Resolved it via raising the version of v7 Support Libraries:

implementation 'com.android.support:appcompat-v7:28.0.0'
dramf
  • 261
  • 3
  • 4
2
  • i have tried enough and getting the same issue as in screen shot and finally got success.

enter image description here

my code was like this..

enter image description here

so after searching enough i solved it by adding maven in my gradle file..

enter image description here

its solved then..

Najaf Ali
  • 1,433
  • 16
  • 26
1

You should add this to build.gradle(module: app)

implementation 'com.android.support:support-vector-drawable:28.0.0'
mutkan
  • 934
  • 8
  • 12
  • I have the same error and I am trying to do it for the last 3 hours. I did what you said,i tried moving google() to top, still cant figure it out . On github, react-bot has closed the issues without any answer. Please help – Kylo Ren Oct 25 '18 at 12:53
0

I try many but only this decoration help me to sync the Gradle, Hope this one help yours

 repositories {
        mavenLocal()
        google()
        jcenter()

    }

And actually add this line to defaultConfig of app module :

vectorDrawables.useSupportLibrary = true
MehrAmoon
  • 187
  • 1
  • 5