Barcode scanning on Android emulator

6,459 views
Skip to first unread message

ryi...@gmail.com

unread,
Dec 8, 2008, 9:03:08 PM12/8/08
to zxing
Hi ,

I'm trying to do barcode scanning using Android emulator. Could anyone
please tell me what steps to follow to do a simple barcode scanning on
the emulator?

Thank for any help,
Ivar

Sean Owen

unread,
Dec 9, 2008, 5:43:40 AM12/9/08
to zxing

R Yell

unread,
Dec 15, 2008, 8:25:31 PM12/15/08
to zx...@googlegroups.com
Hi Sean,

Thanks for the help.

I have few more bugs. I 'm trying to do this :



public class Scan extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        TextView tv = new TextView(this);

        // Reader to read all formats
        Reader reader = new MultiFormatReader();
        File inputFile = new File("C:\\Users\\Yell\\Documents\\Youcam\\barcode1.gif");
        BufferedImage input;
        Result result;
        try {
            input = ImageIO.read(inputFile);
            MonochromeBitmapSource source = new BufferedImageMonochromeBitmapSource(input);
            result = reader.decode(source);
            // Displaying the barcode
            String text = result.getText();
            tv.setText(text);
            setContentView(tv);   
            //byte[] rawBytes = result.getRawBytes();
            //BarcodeFormat format = result.getBarcodeFormat();
            //ResultPoint[] points = result.getResultPoints();
        } catch (IOException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        } catch (ReaderException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } 

       
    }
}

and I'm getting these errors:

[2008-07-09 20:23:15 - Dex Loader] Unable to execute dex: null
[2008-07-09 20:23:15 - BarcodeScan] Conversion to Dalvik format failed: Unable to execute dex: null


Please help!!

Sean Owen

unread,
Dec 20, 2008, 8:32:36 PM12/20/08
to zxing
Well I am guessing there is some earlier error? dex is complaining
about something about the input.

I notice you are using java.awt.BufferedImage. I admit I don't know
off the top of my head -- is this even in the Android SDK? Maybe this
is something the dex compiler doesn't like. More error output would
help.

R Yell

unread,
Dec 24, 2008, 11:21:11 AM12/24/08
to zx...@googlegroups.com
Sean,

I am able to fix this error by changing the heap size of eclipse. But I am encountering a new error.

[2008-07-18 11:15:34 - BarcodeScan] ------------------------------
[2008-07-18 11:15:34 - BarcodeScan] Android Launch!
[2008-07-18 11:15:34 - BarcodeScan] adb is running normally.
[2008-07-18 11:15:34 - BarcodeScan] Could not find BarcodeScan.apk!

This is what I am getting after running the application. I found some people got this error before but couldn't find any answer to this. could you please help me regarding this? I'm pasting the code again.

Thanks in advance,
Ivar


package com.co;

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;


import javax.imageio.ImageIO;

import com.google.zxing.BarcodeFormat;
import com.google.zxing.MonochromeBitmapSource;
import com.google.zxing.MultiFormatReader;
import com.google.zxing.Reader;
import com.google.zxing.ReaderException;
import com.google.zxing.Result;
import com.google.zxing.ResultPoint;
import com.google.zxing.client.j2se.BufferedImageMonochromeBitmapSource;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;



public class Scan extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        TextView tv = new TextView(this);

        // Reader to read all formats
        Reader reader = new MultiFormatReader();
        File inputFile = new File("test.gif");

        BufferedImage input;
        Result result;
        try {
            input = ImageIO.read(inputFile);
            MonochromeBitmapSource source = new BufferedImageMonochromeBitmapSource(input);
            result = reader.decode(source);
            // Displaying the barcode
            String text = result.getText();
            tv.setText(text);
            setContentView(tv);   
            //byte[] rawBytes = result.getRawBytes();
            //BarcodeFormat format = result.getBarcodeFormat();
            //ResultPoint[] points = result.getResultPoints();
        } catch (IOException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        } catch (ReaderException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } 

       
    }
}






Sean Owen

unread,
Dec 24, 2008, 2:11:33 PM12/24/08
to zxing
Is the .apk file in the right place? that seems to be what it is
trying to tell you. It does not seem like an issue with your code;
it's not even finding the .apk file.
Reply all
Reply to author
Forward
0 new messages