如何在Android Build.gradle中替换实现以进行编译.(Android Studio 2.3.3)

Abh*_*mar 4 android build.gradle android-gradle-plugin

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

网址:条码扫描器网址

我的Android Studio版本是2.3.3

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

我搜索过网络编译被 Android studio 3.0中的实现所取代,但我必须在Android studio 2.3.3中使用这个库.

例.

dependencies {
implementation 'com.budiyev.android:code-scanner:1.5.7'
}
Run Code Online (Sandbox Code Playgroud)

当我把它放在我的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'
}
Run Code Online (Sandbox Code Playgroud)

错误是:

    Error:Failed to resolve: com.android.support:support-annotations:26.1.0
    Install Repository and sync project
    Show in Project Structure dialog
Run Code Online (Sandbox Code Playgroud)

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

Int*_*iya 5

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

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