错误:无法解决:support-vector-drawable

ami*_*sni 11 android gradle

我有gradle的问题.它工作正常,但突然间,当我重建项目时,它给了我这个错误:

错误:无法解决:support-vector-drawable

我无法找出我的问题是什么?

我的 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'
} 
Run Code Online (Sandbox Code Playgroud)

Vla*_*sov 34

在我的例子中,我已经在build.gradle配置中将Google repo移到了顶部:

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
  }
}
Run Code Online (Sandbox Code Playgroud)


Jar*_*vis 15

添加vectorDrawables.useSupportLibrary = truedefaultConfig

defaultConfig {
    vectorDrawables.useSupportLibrary = true
}
Run Code Online (Sandbox Code Playgroud)

如果错误仍然存​​在则

allprojects {
 repositories {
    google() // make it first element
    jcenter()
    maven { url 'https://maven.google.com' }
    }
  }
Run Code Online (Sandbox Code Playgroud)

  • 它位于 React Native 项目的哪里?我是新来的反应。 (2认同)

Leo*_*eon 9

我刚刚遇到这个错误和其他一些错误:

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
Run Code Online (Sandbox Code Playgroud)

我没有使用React Native,但在那里找到答案:

android/build.gradle移动jcenter()到底部:

allprojects {
    repositories {
        google()
        maven {
            url 'https://maven.google.com/'
        }
        jcenter()
    }
}
Run Code Online (Sandbox Code Playgroud)


abo*_*ndi 7

我有同样的问题。您必须将 build.gradle 更改为

 // 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
}
Run Code Online (Sandbox Code Playgroud)


Ham*_*ani 7

我在 androidx 项目上遇到了这个错误并解决了它:

1- 在 Build.gradle(模块文件)的 android{} 部分添加:

   vectorDrawables.useSupportLibrary = true
Run Code Online (Sandbox Code Playgroud)

2- 在依赖项 {} 部分,

改变 :

 implementation 'androidx.vectordrawable:vectordrawable:1.0.1'
Run Code Online (Sandbox Code Playgroud)

更新版本:

 implementation 'androidx.vectordrawable:vectordrawable:1.1.0-beta02'
Run Code Online (Sandbox Code Playgroud)

再次编译。