-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Android: Add initial support for Android platform
- Loading branch information
lisah0
committed
Mar 11, 2012
1 parent
8edfa5f
commit 6ed227f
Showing
24 changed files
with
1,153 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="net.sourceforge.zbar.android" | ||
android:versionCode="1" | ||
android:versionName="1.0"> | ||
<application android:label="@string/app_name" > | ||
<activity android:name="ACTIVITY_ENTRY_NAME" | ||
android:label="@string/app_name"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
version 0.1: | ||
* Add initial support for Android platform |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
ZBar Android SDK | ||
================ | ||
|
||
ZBar Bar Code Reader is an open source software suite for reading bar | ||
codes from various sources, such as video streams, image files and raw | ||
intensity sensors. It supports EAN-13/UPC-A, UPC-E, EAN-8, Code 128, | ||
Code 93, Code 39, Codabar, Interleaved 2 of 5, QR Code and | ||
DataBar. These are the JNI wrappers for developing the library on | ||
Android platform. | ||
|
||
Check the ZBar home page for the latest release, mailing lists, etc. | ||
http://zbar.sourceforge.net/ | ||
|
||
Copyright and License | ||
--------------------- | ||
Licensed under the GNU Lesser General Public License, version 2.1. | ||
http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt | ||
|
||
Copyright 2008-2012 � Jeff Brown <[email protected]> et al | ||
|
||
The Android distribution also includes pre-compiled binaries of | ||
supporting libaries, for which copyright, license and source code | ||
locations are as follows: | ||
* The GNU libiconv character set conversion library | ||
Copyright (C) 1999-2011 Free Software Foundation, Inc. | ||
This distribution includes GNU libiconv version 1.14, licensed under | ||
the LGPL version 2. The source code is available from | ||
http://www.gnu.org/software/libiconv | ||
|
||
See included files COPYING and LICENSE for details. | ||
|
||
|
||
Installation | ||
------------ | ||
|
||
After downloading the ZBar-Android-Lib-<version>.zip file, you need to | ||
unzip the file and add it to your Android project. Unzip the file | ||
using your favorite method (ie: command-line, finder, windows | ||
explorer...) | ||
|
||
Follow one of the two options. | ||
Option 1 - via command line | ||
cd <android project> | ||
cp -r ZBar-Android-SDK-<version>/libs . | ||
|
||
Option 2 - via Eclipse | ||
Right click on Android Project | ||
Select "Import" -> "File System" | ||
Select "Browse" (next to "From directory File" and select the | ||
ZBar-Android-SDK-<verion>/libs directory and click "Open". | ||
Click the check box next to "libs" and the "Options" "Create top-level folder" | ||
check box (below). | ||
Then click "Finish". | ||
|
||
You should then see a "libs" folder under your project. | ||
|
||
Building | ||
-------- | ||
|
||
Via Eclipse | ||
You have to add the zbar.jar file to your build path | ||
1) select zbar.jar under libs | ||
2) right-click, select "Build Path" -> "Add to Build Path" | ||
|
||
Via command-line | ||
You are all set; ant will automatcially find jar files under the "libs" | ||
subdirectory. | ||
|
||
Documentation | ||
------------- | ||
TDB | ||
|
||
Examples | ||
-------- | ||
|
||
You should be able to open and build the examples directly from the | ||
unzipped directory. You will need to run the android tools to setup | ||
the local.properties file which sets sdk.dir. | ||
1) cd <unzip dir>/examples/CameraTest | ||
2) android update project --path . | ||
3) ant debug install | ||
|
||
If you have problems with this, please create a new Android project | ||
and copy the necessary files from the examples. | ||
|
||
examples/CameraTest is a simple demonstration of how to integrate the | ||
ZBar image scanner with the camera. | ||
|
||
Manually building ZBar JNI library | ||
---------------------------------- | ||
First download and unzip the iconv library source from | ||
http://www.gnu.org/software/libiconv/ | ||
|
||
Then kick off the build from the ZBar android directory. You will | ||
need to run the android tools to setup the local.properties file which | ||
setups sdk.dir. | ||
|
||
1) cd <zbar project>/android | ||
2) android update project --path . | ||
3) ant -Dndk.dir=<NDK path> -Diconv.src=<iconv library src> zbar-all | ||
|
||
This will rebuild all source files, create zbar.jar and | ||
ZBarAndroidSDK.zip file (which bundles the jar and shared | ||
libraries). From here, you can follow the steps for "Integrating ZBar | ||
JNI library in Android project". | ||
|
||
To clean run: | ||
ant -Dndk.dir=<NDK path> zbar-clean | ||
|
||
See build-ndk.xml for additional target options. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# This file is used to override default values used by the Ant build system. | ||
# | ||
# This file must be checked in Version Control Systems, as it is | ||
# integral to the build system of your project. | ||
|
||
# This file is only used by the Ant script. | ||
|
||
# You can use this to override default values such as | ||
# 'source.dir' for the location of your java source folder and | ||
# 'out.dir' for the location of your output folder. | ||
|
||
# You can also use it define how the release builds are signed by declaring | ||
# the following properties: | ||
# 'key.store' for the location of your keystore and | ||
# 'key.alias' for the name of the key to use. | ||
# The password will be asked during the build when you use the 'release' target. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<!-- | ||
Ant build file to compile the ZBar JNI files using Android NDK tool | ||
targets: | ||
zbar-clean - removes build generated files, build dir, jar and zip files | ||
zbar-ndk-build - builds the zbarjni and iconv shared libraries | ||
zbar-compile - builds the zbar java files | ||
zbar-jar - builds and jars the zbar java files | ||
zbar-zip - Creates ZBarAndroidSDK-x.y.zip of jar, .so, etc | ||
zbar-all - performs all the above :) | ||
--> | ||
<project name="zbar"> | ||
<property name="project.name" value="zbar" /> | ||
<property name="project.sdk.name" value="ZBarAndroidSDK" /> | ||
|
||
<target name="zbar-clean"> | ||
<delete dir="../java/build"/> | ||
<delete file="libs/${project.name}.jar"/> | ||
<delete file="${ant.project.name}.zip"/> | ||
<exec executable="${ndk.dir}/ndk-build" failonerror="true"> | ||
<arg value="clean"/> | ||
</exec> | ||
</target> | ||
|
||
<target name="zbar-ndk-build"> | ||
<exec executable="${ndk.dir}/ndk-build" failonerror="true"> | ||
<arg value="ICONV_SRC=${iconv.src}" /> | ||
</exec> | ||
</target> | ||
|
||
<target name="zbar-compile" depends="zbar-ndk-build"> | ||
<mkdir dir="../java/build" /> | ||
<javac srcdir="../java/net" destdir="../java/build" /> | ||
</target> | ||
|
||
<target name="zbar-jar" depends="zbar-compile"> | ||
<jar destfile="libs/${project.name}.jar" basedir="../java/build"> | ||
</jar> | ||
</target> | ||
|
||
<target name="zbar-zip"> | ||
<if><condition><not><isset property="version"/></not></condition><then> | ||
<property name="version" value="0.1" /> | ||
</then></if> | ||
<zip destfile="${project.sdk.name}-${version}.zip" > | ||
<zipfileset dir="../" prefix="${project.sdk.name}-${version}" includes="COPYING, LICENSE"/> | ||
<zipfileset dir="." prefix="${project.sdk.name}-${version}" includes="README"/> | ||
<zipfileset dir="libs" prefix="${project.sdk.name}-${version}/libs"/> | ||
<zipfileset dir="examples" prefix="${project.sdk.name}-${version}/examples"/> | ||
<zipfileset dir="libs" prefix="${project.sdk.name}-${version}/examples/CameraTest/libs"/> | ||
</zip> | ||
</target> | ||
|
||
<target name="zbar-all" depends="zbar-jar"> | ||
<if><condition><not><isset property="version"/></not></condition><then> | ||
<property name="version" value="0.1" /> | ||
</then></if> | ||
<zip destfile="${project.sdk.name}-${version}.zip" > | ||
<zipfileset dir="../" prefix="${project.sdk.name}-${version}" includes="COPYING, LICENSE"/> | ||
<zipfileset dir="." prefix="${project.sdk.name}-${version}" includes="README"/> | ||
<zipfileset dir="libs" prefix="${project.sdk.name}-${version}/libs"/> | ||
<zipfileset dir="examples" prefix="${project.sdk.name}-${version}/examples"/> | ||
<zipfileset dir="libs" prefix="${project.sdk.name}-${version}/examples/CameraTest/libs"/> | ||
</zip> | ||
</target> | ||
</project> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project name="ZBarAndroidSDK" default="help"> | ||
|
||
<!-- The local.properties file is created and updated by the 'android' tool. | ||
It contains the path to the SDK. It should *NOT* be checked into | ||
Version Control Systems. --> | ||
<property file="local.properties" /> | ||
|
||
<!-- The ant.properties file can be created by you. It is only edited by the | ||
'android' tool to add properties to it. | ||
This is the place to change some Ant specific build properties. | ||
Here are some properties you may want to change/update: | ||
source.dir | ||
The name of the source directory. Default is 'src'. | ||
out.dir | ||
The name of the output directory. Default is 'bin'. | ||
For other overridable properties, look at the beginning of the rules | ||
files in the SDK, at tools/ant/build.xml | ||
Properties related to the SDK location or the project target should | ||
be updated using the 'android' tool with the 'update' action. | ||
This file is an integral part of the build system for your | ||
application and should be checked into Version Control Systems. | ||
--> | ||
<property file="ant.properties" /> | ||
|
||
<!-- The project.properties file is created and updated by the 'android' | ||
tool, as well as ADT. | ||
This contains project specific properties such as project target, and library | ||
dependencies. Lower level build properties are stored in ant.properties | ||
(or in .classpath for Eclipse projects). | ||
This file is an integral part of the build system for your | ||
application and should be checked into Version Control Systems. --> | ||
<loadproperties srcFile="project.properties" /> | ||
|
||
<!-- quick check on sdk.dir --> | ||
<fail | ||
message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through an env var" | ||
unless="sdk.dir" | ||
/> | ||
|
||
|
||
<!-- extension targets. Uncomment the ones where you want to do custom work | ||
in between standard targets --> | ||
<!-- | ||
<target name="-pre-build"> | ||
</target> | ||
<target name="-pre-compile"> | ||
</target> | ||
/* This is typically used for code obfuscation. | ||
Compiled code location: ${out.classes.absolute.dir} | ||
If this is not done in place, override ${out.dex.input.absolute.dir} */ | ||
<target name="-post-compile"> | ||
<copy file="${out.absolute.dir}/classes.jar" tofile="${jar.libs.dir}/zbar_android.jar" /> | ||
</target> | ||
--> | ||
|
||
<!-- Import the actual build file. | ||
To customize existing targets, there are two options: | ||
- Customize only one target: | ||
- copy/paste the target into this file, *before* the | ||
<import> task. | ||
- customize it to your needs. | ||
- Customize the whole content of build.xml | ||
- copy/paste the content of the rules files (minus the top node) | ||
into this file, replacing the <import> task. | ||
- customize to your needs. | ||
*********************** | ||
****** IMPORTANT ****** | ||
*********************** | ||
In all cases you must update the value of version-tag below to read 'custom' instead of an integer, | ||
in order to avoid having your file be overridden by tools such as "android update project" | ||
--> | ||
<!-- version-tag: 1 --> | ||
<import file="build-ndk.xml" /> | ||
<import file="${sdk.dir}/tools/ant/build.xml" /> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="net.sourceforge.zbar.android.CameraTest" | ||
android:versionCode="1" | ||
android:versionName="1.0"> | ||
<uses-sdk android:minSdkVersion="8" /> | ||
<uses-permission android:name="android.permission.CAMERA" /> | ||
<uses-feature android:name="android.hardware.camera" /> | ||
<uses-feature android:name="android.hardware.camera.autofocus" /> | ||
<application android:label="@string/app_name" > | ||
<activity android:name="CameraTestActivity" | ||
android:label="@string/app_name"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# This file is used to override default values used by the Ant build system. | ||
# | ||
# This file must be checked in Version Control Systems, as it is | ||
# integral to the build system of your project. | ||
|
||
# This file is only used by the Ant script. | ||
|
||
# You can use this to override default values such as | ||
# 'source.dir' for the location of your java source folder and | ||
# 'out.dir' for the location of your output folder. | ||
|
||
# You can also use it define how the release builds are signed by declaring | ||
# the following properties: | ||
# 'key.store' for the location of your keystore and | ||
# 'key.alias' for the name of the key to use. | ||
# The password will be asked during the build when you use the 'release' target. | ||
|
Oops, something went wrong.