Zxing 的集成——Maven 對應 Gradle 的寫法
剛剛想耍耍二維碼,想到了zxing
和zbar
,又想到zxing
是Google
老爹的,想想就算了吧,雖然zbar
快但是識別錯誤率也高不少.隨手Google
了下*zxing 集成*
好像都是說什麼拷貝項目到自己的工程中,我不信Gradle
集成這麼方便了為何不用.於是我來到zxing
的 Github 主頁https://github.com/zxing/zxing,在README
的引導下來到Get Start
頁面,裡面有如下說明:
Maven
core/, javase/, android-integration and zxingorg can be used directly in a Maven-based project without any download or installation. Instead, add as dependencies from groupID com.google.zxing artifactIDs core, javase, android-integration or zxingorg:
...
雖然沒說明 Gradle 如何集成,但是發布過lib到jcenter
的應該知道,maven
和Gradle
的關係.
上面maven
倉庫信息對應的Gradle
為:
compile "com.google.zxing:core:3.3.0"
compile " 記起來也很簡單,就是把上面三個參數用 其中 所以在 Android studio 的工程 其他的項目集成以此類推.
:
連接即可.version
對應版本有很多,建議使用最新的,我現在看到最新的Release
版本為3.3.0
.Module
的build.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:25.3.1"
compile "com.android.support:support-v4:25.3.1"
compile "com.android.support:design:25.3.1"
compile "com.android.support.constraint:constraint-layout:1.0.2"
testCompile "junit:junit:4.12"
//添加 zxing
compile "com.google.zxing:core:3.3.0"
}


※尚學堂高琪JAVA300篇視頻筆記(31-37)
※koa-router中路由/後面不填參數就會報404的解決辦法
※在Eclipse IDE使用Gradle構建應用程序
※收集的常用簡單的演算法
TAG:達人科技 |