7

I'm trying to import Google's ZXing.

I downloaded the latest release from https://code.google.com/p/zxing/downloads/detail?name=ZXing-2.2.zip&can=2&q=

From the cmd prompt I navigated to the root directory of the downloaded zxing and tried to execute

ant -f core\build.xml

PROBLEM :

Buildfile : build.xml does not exist!

Build failed

My zxing-2.2/core file contains :

src

test

pom.xml

Questions: How to build a file that is missing? Is it a problem from the zxing-2.2.jar I downloaded?

Community
  • 1
  • 1
Sorikane
  • 71
  • 1
  • 2

5 Answers5

10

This problem happened to me too, I solved it by creating the build.xml file inside core folder

change name="whatever you want" in the second line, here it's "project"

code of build.xml:

<?xml version="1.0" encoding="utf-8" ?>
<project name="project" default="jar" basedir=".">

    <target name="compile" description="Compile source">
        <mkdir dir="bin" />
        <javac srcdir="src" includes="**" destdir="bin"/>
        <copy todir="bin">
            <fileset dir="src" />
        </copy>
    </target>

    <target name="jar" description="Package into JAR" depends="compile">
        <jar destfile="project.jar" basedir="bin" compress="true" />
    </target>
</project>

Run the build command again and see if it works.

alaswer
  • 135
  • 9
  • I created build.xml `downloads\zxing-2.2\core>ant -f core/build.xml` and when I run the build again it says _'ant' is not recognized as an internal or external command_ – DroidLearner Aug 26 '13 at 07:13
  • 1
    thanks a lot . it worked fine . instead of src directory . I modified to src\main to avoid test folder – AMH Mar 16 '15 at 13:51
3

Please do consider that you can always use the pom.xml to achieve the same. This is the method prescribed in the official zxing documentation https://code.google.com/p/zxing/wiki/GettingStarted The commands I have used are as follows: cd core mvn -DskipTests -Dgpg.skip=true install

That's it, you are done. Obviously, maven is to be installed before using the code

2

I tried the accepted answer, but unfortunately it not worked. Actually the jar was built successfully, but it was not built into the apk when Eclipse built the project. This was when i referenced ZXing as a library project. I managed to write an ant script which works, so i share it here:

<?xml version="1.0" encoding="utf-8" ?>
<project name="core" basedir="." default="dist" >

    <property name="dist.dir" value="dist" />
    <property name="src.dir" value="src" />
    <property name="build.dir" value="bin" />

    <target name="dist" depends="clean, package" />
    <target name="clean" >
        <delete dir="${build.dir}" />
    </target>
    <target name="init" >
        <mkdir dir="${build.dir}" />
    </target>
    <target name="compile" >
        <javac debug="off" destdir="${build.dir}" source="1.6" srcdir="${src.dir}" target="1.6" />
    </target>
    <target name="package" depends="init, compile" >
        <jar basedir="${build.dir}" destfile="${dist.dir}/core.jar" />
    </target>

</project>
WonderCsabo
  • 11,947
  • 13
  • 63
  • 105
2

If you just need the core.jar from zxing, you can skip that process and get the pre-built JARs from the GettingStarted wiki page

Core.jar is the library solution to integrate zxing in your app

(the other option is via Intent but BarcodeScanner.apk is needed)

For zxing2.2, you can obtain the core.jar from the zxing Maven repository here

Josu Garcia de Albizu
  • 1,128
  • 2
  • 12
  • 22
0

Zxing 2.2 and above don't include core/build.xml

If the original file is necessary I recommend using Zxing 2.1, which can be found here: https://code.google.com/p/zxing/downloads/detail?name=ZXing-2.2.zip&can=2&q=

Orane
  • 2,223
  • 1
  • 20
  • 33