當前位置:
首頁 > 知識 > Zxing 的集成——Maven 對應 Gradle 的寫法

Zxing 的集成——Maven 對應 Gradle 的寫法

剛剛想耍耍二維碼,想到了zxingzbar,又想到zxingGoogle老爹的,想想就算了吧,雖然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:


...

com.google.zxing
core
(the current version)


雖然沒說明 Gradle 如何集成,但是發布過lib到jcenter的應該知道,mavenGradle的關係.

上面maven倉庫信息對應的Gradle為:

compile "com.google.zxing:core:3.3.0"

compile "::"

記起來也很簡單,就是把上面三個參數用:連接即可.

其中 version對應版本有很多,建議使用最新的,我現在看到最新的Release版本為3.3.0.

所以在 Android studio 的工程 Modulebuild.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:達人科技 |

您可能感興趣

開源框架Zxing生成二維碼流程分析