-
Notifications
You must be signed in to change notification settings - Fork 0
Getting Started Developing
If you just need a pre-built JAR file, you can always find compiled resources from the Maven release repository, including recent snapshot/nightly builds.
Download the latest release, version 3.0.0 or later. Or, retrieve the latest source code from Github.
The code is organized into several subdirectories, corresponding to modules, like core/
and javase/
. Within each Java-based module, there is a pom.xml
file for use with Apache Maven.
A few configuration steps are needed, depending on which modules you want to build. From the directory where you unpacked or checked out the source code:
The Android SDK must be installed of course. Run the tool called android
and ensure that platform support for the latest Android release is installed. At the time of this writing, that's platform level 19 / Android 4.4.
android update project --path android
or
echo "sdk.dir=/change/this/path/to/android-sdk" > android/local.properties
export ANDROID_HOME=/change/this/path/to/android-sdk
- Build
core/
below, first - Run
ant debug
fromandroid/
to build the Barcode Scanner application asbin/Barcode Scanner-debug.apk
.
From android/
, run mvn package android:apk
to produce a compile .apk
file in target
. Use android-x.y.z-aligned.apk
.
Other users will not be able to build the signed release version, but the command is: mvn -Pandroid-release -Djarsigner.storepass=... -Djarsigner.keypass=... clean package android:apk
.
From android-integration/
, run mvn package
to produce compiled libraries like android-integration-x.y.z.jar
in the target/
directory.
From core/
, run mvn -DskipTests package
to product compiled libraries like core-x.y.z.jar
in the target/
directory.
From javase/
, run mvn package
to product compiled libraries like javase-x.y.z.jar
in the target/
directory.
From zxingorg/
, run mvn package
to produce a .war
in the target/
directory.
Most components are libraries and are not run directly.
- Build
android/
- Connect your device via USB
- If you already have the standard version of Barcode Scanner installed, uninstall it
- Make sure your device is set to allow apps from untrusted sources
- In release 3.0.0 and earlier, run
ant installd
to install the debug build. In release 3.1.0 and later, runmvn android:deploy
.
After building, simply run this class with java
from the top-level directory:
java -cp javase/target/javase-x.y.z.jar:core/target/core-x.y.z.jar com.google.zxing.client.j2se.CommandLineRunner [URL | FILE]
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.
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>3.0.0</version>
</dependency>
</dependencies>