zxing简介与核心库编译

来源:互联网 发布:vb版电子教室 编辑:程序博客网 时间:2024/05/20 16:43

简介

ZXing (pronounced "zebra crossing") is an open-source, multi-format 1D/2D barcode image processing library implemented in Java, with ports to other languages. Our focus is on using the built-in camera on mobile phones to scan and decode barcodes on the device, without communicating with a server. However the project can be used to encode and decode barcodes on desktops and servers as well. We currently support these formats:

  • UPC-A and UPC-E
  • EAN-8 and EAN-13
  • Code 39
  • Code 93
  • Code 128
  • ITF
  • Codabar
  • RSS-14 (all variants)
  • RSS Expanded (most variants)
  • QR Code
  • Data Matrix
  • Aztec ('beta' quality)
  • PDF 417 ('alpha' quality)
  • core: The core image decoding library, and test code

  • ZXing源码可以从https://code.google.com/p/zxing/downloads/list下载,这里下载ZXing-2.3.0.zip。解压之后得到的就是ZXing源码,有用的是android文件夹和core文件夹。core文件夹是二维码的核心库,可以编译生成jar供其他工程使用。android文件夹里放的是一个android工程CaptureActivity,使用Eclipse打开之后会发现很多错误,就是因为缺少core编译出来的jar文件。可以直接去http://repo1.maven.org/maven2/com/google/zxing/下载jar包放入CaptureActivity工程中的libs文件夹下, 使得这个工程可以编译运行。也可以自己根据core源码编译出jar。供CaptureActivity使用。

编译core过程

  • 编译core过程如下:我的环境是XP,使用adt bundle
    1、配置ant,adt bundle内含ant,所以不用下载,只要设置下环境变量就行。我是在path里添加 D:\adt-bundle-windows-x86-20130917\adt-bundle-windows-x86-20130917\eclipse\plugins\org.apache.ant_1.8.3.v201301120609\bin  (也可以在http://ant.apache.org/bindownload.cgi这个里面下载ant,记得把ant的bin路径配置在path中方便使用就好)
    2、配置android环境变量,在path中加入D:\adt-bundle-windows-x86-20130917\adt-bundle-windows-x86-20130917\sdk\tools                           
    3、下载maven http://maven.apache.org/download.cgi,配置环境变量,path中加入D:\apache-maven-3.1.1-bin\apache-maven-3.1.1\bin。使用mvn -version验证是否成功,成功如下图所示。

               

      


  • 4、从命令行进入到ZXing-2.3.0目录下:

      输入如下命令:

      android update project --path android

      成功后就可以看到\ZXing-2.3.0\android目录下新增了一个名为local.properties的文件,里面内容是:sdk.dir=你的Android SDK目录

  • 5、编译jar包

      命令行进入到\core路径下,输入命令:

      mvn -DskipTests -Dgpg.skip=true install

      运行完之后core目录下会生成一个target目录。

      里面就有编译好的各种东西,包括文档、需要的Jar包等(比如我的这个叫core-2.3.0.jar)。


  • 6、把这个jar放入CaptureActivity工程中的libs目录下就可以编译运行了。

  • 参考文献:

  • http://www.cnblogs.com/mengdd/p/3289145.html

  • https://code.google.com/p/zxing/wiki/GettingStarted

  • 转载自:http://blog.csdn.net/yuxmdef1/article/details/17793461


0 0
原创粉丝点击