This question already has answers here:
Failed to resolve: com.android.support:cardview-v7:26.0.0 android

(26 个回答)



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

(14 个回答)


3年前关闭。




我正在开发条形码扫描仪的应用程序。

网址:Barcode Scanner URL Here

我的 Android Studio 版本是 2.3.3

我总是在 build.gradle (module:app) 中使用 compile 但我发现这个库建议使用 实现 代替 compile

我在互联网上搜索 compile 在 Android studio 3.0 中被 implementation 取代,但我必须在 Android studio 2.3.3 中使用这个库。

示例。
dependencies {
implementation 'com.budiyev.android:code-scanner:1.5.7'
}

当我把它放在我的 gradle 中时,它的显示错误。
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.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.budiyev.android:code-scanner:1.5.7' // HERE
testCompile 'junit:junit:4.12'
}

错误是:
    Error:Failed to resolve: com.android.support:support-annotations:26.1.0
    Install Repository and sync project
    Show in Project Structure dialog

请告诉我如何在我的 android studio 2.3.3 中使用这个库

最佳答案

您需要在顶级 build.gradle 中添加 Google 的 Maven 存储库

      allprojects {
      repositories {
        google()

        // If you're using a version of Gradle lower than 4.1, you must instead use:
        // maven {
        //     url 'https://maven.google.com'
        // }
        // An alternative URL is 'https://dl.google.com/dl/android/maven2/'
    }
}

关于android - 如何替换实现以在 Android Build.gradle 中编译。 (安卓工作室 2.3.3),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/46731608/

10-12 03:39