Zxing 的集成 ---- Maven 对应 Gradle 的写法
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:
<dependencies>
...
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>core</artifactId>
<version>(the current version)</version>
</dependency>
</dependencies>
虽然没说明 Gradle 如何集成,但是发布过lib到jcenter
的应该知道,maven
和Gradle
的关系.
上面maven
仓库信息对应的Gradle
为:
compile 'com.google.zxing:core:3.3.0'
compile '<groupId>:<artifactId>:<version>'
记起来也很简单,就是把上面三个参数用:
连接即可.
其中 version
对应版本有很多,建议使用最新的,我现在看到最新的Release
版本为3.3.0
.
所以在 Android studio 的工程 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'
}
其他的项目集成以此类推.
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· Docker 太简单,K8s 太复杂?w7panel 让容器管理更轻松!