1

I have resently bought the OnBarcode Library for android, when I got the email saying what I needed to download I got a .jar file, I added that file into a lib folder that I made within my app. Then I went to the properties of my project where I went to "Java Build Path" I added that jar file to my app like that. Next, I added some code into on View Class and in the onDraw section I added testQRCode(canvas) the code for that is

private static void testQRCode(Canvas canvas) throws Exception
    {
        QRCode barcode = new QRCode();

        barcode.setData("test;");
        barcode.setDataMode(QRCode.M_AUTO);
        barcode.setVersion(1);
        barcode.setEcl(QRCode.ECL_L);

        barcode.setFnc1Mode(IBarcode.FNC1_NONE);

        barcode.setProcessTilde(false);

        barcode.setUom(IBarcode.UOM_PIXEL);
        barcode.setX(3f);

        barcode.setLeftMargin(50f);
        barcode.setRightMargin(50f);
        barcode.setTopMargin(50f);
        barcode.setBottomMargin(50f);
        barcode.setResolution(72);

        barcode.setForeColor(AndroidColor.black);
        barcode.setBackColor(AndroidColor.white);

        RectF bounds = new RectF(0, 0, 100, 100);
        barcode.drawBarcode(canvas, bounds);
    }

The finaly when I try to run my app I get an error that says java.lang.NoClassDefFoundError: com.onbarcode.barcode.android.QRCode what have I done wrong im kinda stressing our over this because this cost bout $800 to buy and that its crashing in scaring me. Do you guys have any ideas on what Im doing wrong? Thanks.

Michael Zeuner
  • 1,736
  • 3
  • 15
  • 23
  • "Then I went to the properties of my project where I went to "Java Build Path" I added that jar file to my app like that" -- if you are on the R16 or newer edition of the ADT plugin for Eclipse, this step is not needed and may cause problems. Just adding the JAR to a `libs/` directory (note the plural) should suffice. – CommonsWare Aug 13 '12 at 12:23

2 Answers2

1

May try this :

-> Right click on your project
-> Go into Build Path
-> Configure Build Path 
-> Go to Order and Export
-> Check your OnBarcode library
-> Clean your project

It has solve my problem when I tried to add a library and I get the same error like you.

Alexis C.
  • 91,686
  • 21
  • 171
  • 177
  • Where should I see clean in `Order and Export` because at the bottom there is only OK and Cancel – Michael Zeuner Aug 13 '12 at 12:34
  • After checking your library, click on Ok. Then on the Eclipse tools bar at the top of your screen, click on Project -> Clean -> Check your project -> click on Ok – Alexis C. Aug 13 '12 at 12:36
0

Have you added the .jar file into your projects 'libs' directory? If not, add it in, do a refresh of the project in eclipse, right click on the .jar file then click Build Path > Add to build path.

JDx
  • 2,615
  • 3
  • 22
  • 33