My favorites | Sign in
Google
                
Search
for
Updated Jun 26, 2009 by dswit...@gmail.com
Labels: Featured
GettingStarted  
How to start developing with zxing

Getting Started

Please also read CodingStyle if you'd like to contribute to the project. You can also see DeveloperNotes for more information.

Download

Grab the latest distribution. Or, retrieve the latest source code from our Subversion repository.

Build

You will find the code lives in several subdirectories, corresponding to the various subcomponents, like "core" and "javase". Within each, there is a build.xml Ant build file which controls building of that component. If Apache's ant tool is already present on your system, simply type "ant" to build that component. See http://ant.apache.org for details on how to obtain this free, standard build tool for Java.

To build everything, simply use the build.xml file found in the top-level directory, above all components. Yes, just type ant there.

Run

The quickest way to run the code is to run the "javase" component's com.google.zxing.client.j2se.CommandLineRunner class against a URL.

As above, first build core and javase:

 cd core
 ant
 cd ../javase
 ant

After building, simply run this class with java:

 cd ..
 java -cp javase/javase.jar:core/core.jar com.google.zxing.client.j2se.CommandLineRunner [URL]

Windows users take note; path syntax is different on Windows. Here and elsewhere you will need to use ';' rather than ':' to separate classpath elements, and likely need to use the '\' path separator. So that last command should be:

 java -cp javase\javase.jar;core\core.jar com.google.zxing.client.j2se.CommandLineRunner [URL]

Run on your phone

You can build the J2ME client too.

  • Download and install Sun's Java Wireless Toolkit 2.5.2
  • At the top level of the project, edit build.properties to reference the location where you installed WTK.
  • Download Proguard, and copy proguard.jar to the bin directory under the WTK 2.5.2 installation directory.
  • Build core and then javame:
  •  cd core
     ant
     cd ../javame
     ant
  • Refer to instructions for your particular phone model to learn how to load this application onto your device

Run on Android

  • Download and install the latest public Android SDK.
  • Edit build.properties at the top level of the project, and change the android-home property to point to the SDK install location
  • Build core and then android. Note that core must be built without debug symbols to avoid an incompatibility between proguard and the Android tool chain:
  •  cd core
     ant clean build-no-debug
     cd ../android
     ant
  • The application should be built to bin/BarcodeScanner-debug.apk. Install with Android's adb tool:
  •  adb install bin/BarcodeScanner-debug.apk

Comment by nanodeath, Mar 12, 2008

Can we see some android-specific "Getting Started" comments? Thanks!

Comment by sro...@gmail.com, Mar 12, 2008

Will do. It's about the same. At the moment we only have a build available that works with the M3 SDK, not M5 or later. So you can't run this on the emulator at the moment (but the additional changes needed for M5 are small). But even if you could run it, you wouldn't have a video feed to decode (though there are workarounds for that even...) For the moment, for testing reasons, it's convenient for us to stick on M3 -- while it's of little use to anyone else. But yeah we need to move forward soon in any event.

Comment by nanodeath, Mar 16, 2008

Okay. It's not a huge hurry -- the first gphones are still a ways off (I think) and I still have plenty of other things to work on.

Oh, and great work so far. I actually was able to port everything from M3 to M5 myself except for a couple of important things that...coincidentally were essential to the library's functioning. Some stuff related to bitmaps, I believe.

Comment by sro...@gmail.com, Mar 16, 2008

Can you file an issue or start a thread at http://groups.google.com/group/zxing/ describing the issue? I got it compiling on M5 but have not verified it works completely, since there's no real video feed available to the emulator.

Comment by christopher.orr, May 15, 2008

Note that building core (i.e. not only the J2ME version) requires WTK.

Comment by matt.hall, Jul 09, 2008

For Mac users you can use some of the information at http://javablog.co.uk/2008/01/17/j2me-development-on-os-x-revisited/ to put together a semi working WTK out of the Linux WTK download and the preverify binary from the phoneme project. It seems to be enough to compile the project at least.

Comment by leroyale, Sep 27, 2008

Does not work with the last android sdk android-sdk-windows-1.0_r1 since packages are different from android-sdk-windows-0.9_beta

Comment by leybzon, Oct 28, 2008

With the latest Android emulator, I can not upload test image into the emulator:

adb push c:barcode.jpg /tmp/barcode.jpg failed to copy 'c:barcode.jpg' to '/tmp/barcode.jpg': No such file or directory

Also can not create /tmp directory within the device: adb shell mkdir /tmp mkdir failed for /tmp, Read-only file system

Comment by sro...@gmail.com, Oct 29, 2008

Looks like you have a typo in your command line? "c:barcode.jpg"? I don't think you need to create /tmp, it should already be there.

Continue this on the Google Group instead? http://groups.google.com/group/zxing/

Comment by nambrot, Nov 08, 2008

Hi does the iphone version support openURL schemes to open Applications? Would be really nice, as deveopers can display a code on the screen and opens an application.

Comment by ryivar, Dec 08, 2008

Hi..I am a beginner and trying to do a barcode scanning project.could anyone tell me how to scan a barcode using webcam/android emulator? Please advise me where to start from. Your help is always appreciated.

Comment by credentiality, Jan 06, 2009

ZXing doesn't seem to work with proguard 3.9, which is what you get with Ubuntu Hardy as of January 2009. Download version 4.1 or later.

If proguard is too old you'll get errors like "unknown option -target".

Comment by email.rafa, Feb 10, 2009

Is there a getting started guide for iPhone developers? thanks!

Comment by weiguo10, May 19, 2009

I cannot build the android version for cupcake(1.5), it give following error

..\zxing\android\build.xml:125: Execute failed: java.io.IOException: Cannot run program "D:\android-sdk-windows-1.5_r1\tools\aapt.exe": CreateProcess? error=2, ?????????

aapt can only be found in android 1.1 and before

Comment by sro...@gmail.com, May 19, 2009

Yes, at the moment the code compiles against the 1.1 SDK so that the application can be built and used on 1.1 devices. Not every device has 1.5 yet, but 1.5 can run the 1.1-built application. Later when 1.5 is the norm we can change the build process to work with the 1.5 SDK.

Comment by michael573114, Jun 24, 2009

Perhaps you could provide a 1.5 SDK version as well as the 1.1? There's little reason to develop new apps for 1.1 anymore, regardless of wether "not all device has 1.5 yet"

Comment by janrunejohansen, Jun 26, 2009

I do agree with Michael. 1.5 devices is not the future. Its allready here...


Sign in to add a comment