2017-10-13 111 views
2

我正在開發一款條碼掃描器應用程序。如何替換實現以在Android Build.gradle中編譯。 (Android Studio 2.3.3)

網址:Barcode Scanner URL Here

我的Android Studio版本2.3.3是

我一直在使用的build.gradle編譯(模塊:應用程序),但我發現這個庫建議使用實施在更換編譯

我搜索了網上編譯由Android的工作室3.0 實施替換,但我在的Android 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工作室使用這個庫2.3.3

回答

3

您需要添加谷歌的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/' 
    } 
} 
+0

遺憾地說,什麼都不會發生同樣的錯誤消息。我加入了build.gradle編譯'com.budiyev.android:code-scanner:1.5.7',我替換了實現來編譯。 –

+1

@Abhishekkumar按照https://github.com/yuriy-budiyev/code-scanner,你應該使用'implementation'com.budiyev.android:code-scanner:1.5.7''。 –

+1

@IntelliJAmiya權利 –

1

到您的項目水平gradle這個添加的Maven回購這樣的:

allprojects { 
    repositories { 

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

這是Android Studio版本2.3.3或搖籃版本低於4.1

+0

我加了但是也出現了相同的錯誤信息。 –

+0

你的buildToolsVersion是什麼? –

+0

classpath'com.android.tools.build:gradle:2.3.3' –

相關問題