i get a stack overflow error while trying to draw a qr code in canvas,
saying unable to create .dex file and prompting to close eclipse, even
i changed memory in eclipse.ini but nothing worked

here is the QRcodeActivity.java file

   package karthick.vampire;

    import android.app.Activity;
    import android.os.Bundle;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.EditText;

    public class QRcodeActivity extends Activity {
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);

            final QRView qr = (QRView) findViewById(R.id.qr);

            final EditText input = (EditText) findViewById(R.id.text);

            Button button = (Button) findViewById(R.id.button);
            button.setOnClickListener(new OnClickListener() {

                 public void onClick(View v) {
                    qr.changeData(input.getText().toString());
                }
            });

        }
    }


QRview.java file

 package karthick.vampire;

    import android.content.Context;
    import android.graphics.Canvas;
    import android.graphics.RectF;
    import android.util.AttributeSet;
    import android.view.View;

    import com.onbarcode.barcode.android.AndroidColor;
    import com.onbarcode.barcode.android.IBarcode;
    import com.onbarcode.barcode.android.QRCode;

    public class QRView extends View {

String data = "";

public QRView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
}

public QRView(Context context, AttributeSet attrs) {
    super(context, attrs);
}

public QRView(Context context) {
    super(context);
}

public void changeData(String data) {
    this.data = data;
    invalidate();
}

@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    QRCode barcode = new QRCode();

    /*
     * QRCode Valid data char set: numeric data (digits 0 - 9);
alphanumeric
     * data (digits 0 - 9; upper case letters A -Z; nine other
characters:
     * space, $ % * + - . / : ); byte data (default: ISO/IEC 8859-1);
Kanji
     * characters
     */
    barcode.setData(data);
    barcode.setDataMode(QRCode.M_AUTO);
    barcode.setVersion(10);
    barcode.setEcl(QRCode.ECL_M);

    // if you want to encode GS1 compatible QR Code, you need set FNC1
mode
    // to IBarcode.FNC1_ENABLE
    barcode.setFnc1Mode(IBarcode.FNC1_NONE);

    // Set the processTilde property to true, if you want use the
tilde
    // character "~" to
    // specify special characters in the input data. Default is false.
    // 1-byte character: ~ddd (character value from 0 ~ 255)
    // ASCII (with EXT): from ~000 to ~255
    // 2-byte character: ~6ddddd (character value from 0 ~ 65535)
    // Unicode: from ~600000 to ~665535
    // ECI: from ~7000000 to ~7999999
    // SJIS: from ~9ddddd (Shift JIS 0x8140 ~ 0x9FFC and 0xE040 ~
0xEBBF)
    barcode.setProcessTilde(false);

    // unit of measure for X, Y, LeftMargin, RightMargin, TopMargin,
    // BottomMargin
    barcode.setUom(IBarcode.UOM_PIXEL);
    // barcode module width in pixel
    barcode.setX(3f);

    barcode.setLeftMargin(15f);
    barcode.setRightMargin(15f);
    barcode.setTopMargin(15f);
    barcode.setBottomMargin(15f);
    // barcode image resolution in dpi
    barcode.setResolution(72);

    // barcode bar color and background color in Android device
    barcode.setForeColor(AndroidColor.black);
    barcode.setBackColor(AndroidColor.white);

    /*
     * specify your barcode drawing area
     */
    RectF bounds = new RectF(30, 30, 0, 0);
    try {
        barcode.drawBarcode(canvas, bounds);
    }
catch (Exception e) {
        e.printStackTrace();
    }
}
 }

in order to draw the barcodes i included an external jar file into my
libs folder and added it to the build path
downloaded the above mentioned jar file from
http://www.onbarcode.com/tutorial/android-barcode-generation-guide.html
-> www.onbarcode.com/products/android_barcode/file_download.php

my main.xml file

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="center"
    android:orientation="vertical" >

    <EditText
        android:id="@+id/text"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:hint="Write here and click the button"
        android:singleLine="true" />

    <Button
        android:id="@+id/button"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Click Here!" />

    <karthick.vampire.QRView
        android:id="@+id/qr"
        android:layout_width="300dp"
        android:layout_height="0dp"
        android:layout_weight="1" />

</LinearLayout>


my error

 Unable to execute dex: java.lang.StackOverflowError. Check the
Eclipse log for stack trace.
    Conversion to Dalvik format failed: Unable to execute dex:
java.lang.StackOverflowError. Check the Eclipse log for stack trace.

eclipse.ini file

    -startup
    plugins/org.eclipse.equinox.launcher_1.1.1.R36x_v20101122_1400.jar
    --launcher.library
    plugins/
org.eclipse.equinox.launcher.gtk.linux.x86_1.1.2.R36x_v20101019_1345
    -product
    org.eclipse.epp.package.java.product
    --launcher.defaultAction
    openFile
    -showsplash
    org.eclipse.platform
    --launcher.XXMaxPermSize
    1024m
    --launcher.defaultAction
    openFile
    -vmargs
    -Dosgi.requiredJavaVersion=1.5
    -XX:MaxPermSize=1024m
    -Xms512m
    -Xmx1024m


the same project executes well in windows xp and vista, but not in
ubuntu and opensuse, is any problem with the linux versions ,are these
not suitable for android development???

do u see any recursion in my java files, if not please give me a
solution to this "stack over flow error" friends else correct my
program

waiting for your reply
karthick.s
knowledge is tree

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to