【问题标题】:Installing and using OnBarcode Library安装和使用 OnBarcode 库
【发布时间】:2012-08-13 12:20:45
【问题描述】:

我最近购买了适用于 Android 的 OnBarcode 库,当我收到电子邮件说我需要下载什么时,我得到了一个 .jar 文件,我将该文件添加到我在我的应用程序中创建的 lib 文件夹中。然后我去了我的项目的属性,在那里我去了“Java Build Path”,我把那个jar文件添加到我的应用程序中。接下来,我在 View Class 中添加了一些代码,并在 onDraw 部分添加了testQRCode(canvas) 的代码

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);
    }

最后,当我尝试运行我的应用程序时,我收到一条错误消息,上面写着 java.lang.NoClassDefFoundError: com.onbarcode.barcode.android.QRCode 我做错了什么,我有点强调我们对此的压力,因为这要花 800 美元购买,而且它吓坏了我。你们对我做错了什么有什么想法吗?谢谢。

【问题讨论】:

  • “然后我转到我的项目的属性,在那里我转到“Java Build Path”,我像这样将那个 jar 文件添加到我的应用程序中”——如果您使用的是 R16 或更新版本Eclipse 的 ADT 插件,这一步不需要,可能会导致问题。只需将 JAR 添加到 libs/ 目录(注意复数)就足够了。
  • 谢谢你,你解决了我的问题!!!!

标签: android generator barcode qr-code


【解决方案1】:

可以试试这个:

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

当我尝试添加一个库时,它解决了我的问题,我得到了和你一样的错误。

【讨论】:

  • 我应该在Order and Export 哪里看到干净,因为在底部只有 OK 和 Cancel
  • 检查您的图书馆后,单击确定。然后在屏幕顶部的 Eclipse 工具栏上,点击 Project -> Clean -> Check your project -> 点击 Ok
【解决方案2】:

您是否已将 .jar 文件添加到您的项目“libs”目录中?如果没有,请添加它,在 eclipse 中刷新项目,右键单击 .jar 文件,然后单击 Build Path > Add to build path。

【讨论】:

  • 我第一次这样做了,现在我重新做了,我仍然得到同样的错误。
猜你喜欢
  • 2014-04-26
  • 1970-01-01
  • 1970-01-01
  • 2014-10-18
  • 1970-01-01
  • 1970-01-01
  • 2018-05-22
  • 1970-01-01
  • 2013-11-19
相关资源
最近更新 更多