Stack Exchange
QR code GENERATION Error
i want to generate qr code from string and search stackoverflow, but when i use these codes, i have error "unexpectly... " !!!
this is my code.
can any body say where i am wrong ?
besides i need another code for giving me string from qr code ...
thanks
 import android.app.Activity;
 import android.graphics.Bitmap;
 import android.graphics.Color;
 import android.os.Bundle;
 import android.widget.ImageView;
  import com.google.zxing.BarcodeFormat;
  import com.google.zxing.WriterException;
  import com.google.zxing.common.BitMatrix;
  import com.google.zxing.qrcode.QRCodeWriter;


public class StringtoQRActivity extends Activity {

public final static int    WHITE = 0xFFFFFFFF;
public final static int    BLACK = 0xFF000000;
public final static int    WIDTH = 500;
public final static String STR   = "amirahmad";


@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    ImageView imageView = (ImageView) findViewById(R.id.QRcode);
    Bitmap bitmap = encodeToQrCode(STR, WIDTH, WIDTH);
    imageView.setImageBitmap(bitmap);
    }


public static Bitmap encodeToQrCode(String text, int width, int height) {
    QRCodeWriter writer = new QRCodeWriter();
    BitMatrix matrix = null;
    try {
        matrix = writer.encode(text, BarcodeFormat.QR_CODE, 100, 100);
    }
    catch (WriterException ex) {
        ex.printStackTrace();
    }
    Bitmap bmp = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);
    for (int x = 0; x < width; x++) {
        for (int y = 0; y < height; y++) {
            bmp.setPixel(x, y, matrix.get(x, y) ? Color.BLACK :        Color.WHITE);
        }
    }
    return bmp;
}
 }


"unexpectly... " does not explain anything. Please post the complete crash logcat.

05-13 14:24:12.956: E/AndroidRuntime(1041): java.lang.NoClassDefFoundError: com.google.zxing.qrcode.QRCodeWriter

05-13 14:24:12.466: E/dalvikvm(1041): Could not find class 'com.google.zxing.qrcode.QRCodeWriter', referenced from method com.test.stringtoQR.StringtoQRActivity.encodeToQrCode
