0

我正在使用 Biggu 条形码库。

打包的库已经列出了使用演示和示例应用程序的所有内容。

但我没有找到类定义错误

     java.lang.NoClassDefFoundError: com.biggu.scannerdemo.ScannerActivity

但是该类在包中,并且清单文件列出了所有活动。构建路径biggu_scanner-1.1.0.jar在其路径中有文件。

package com.biggu.scannerdemo;

import com.biggu.barcodescanner.client.android.Intents;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class Demo extends Activity {

private static final int SCANNER_REQUEST_CODE = 0;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

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

        public void onClick(View v) {

            Intent intent = new Intent(v.getContext(), com.biggu.scannerdemo.ScannerActivity.class);
            intent.putExtra(Intents.Preferences.ENABLE_BEEP, true);
            intent.putExtra(Intents.Preferences.ENABLE_VIBRATE, true);

            ((Activity)v.getContext()).startActivityForResult(intent, SCANNER_REQUEST_CODE);
        }
    });
}

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {

    if (resultCode == Activity.RESULT_OK && requestCode == SCANNER_REQUEST_CODE) {

        Bundle extras = data.getExtras();
        String result = extras.getString("SCAN_RESULT");
        TextView textView = (TextView)findViewById(R.id.txt);
        textView.setText(result);
    }
}}

ScannerActivity 具有以下代码

package com.biggu.scannerdemo;

import com.biggu.barcodescanner.client.android.CaptureActivity;

public class ScannerActivity extends CaptureActivity {

@Override
public int get_R_id_preview_view() {

    return R.id.preview_view;
}

@Override
public int get_R_id_viewfinder_view() {

    return R.id.viewfinder_view;
}

@Override
public int get_R_layout_scanner() {

    return R.layout.scanner;
}

@Override
public int get_R_raw_beep() {

    return R.raw.beep;
}
}

安卓清单文件

<?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.biggu.scannerdemo"
  android:versionCode="1"
  android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
    <activity android:name=".Demo"
              android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity android:name=".ScannerActivity"
        android:label="Scanner Activity" android:screenOrientation="landscape"
        android:configChanges="orientation|keyboardHidden" android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
    </activity>

</application>
<uses-sdk android:minSdkVersion="4" />

<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.FLASHLIGHT" />

尝试一切设置正确谁能让我知道代码中可能有什么问题。期待您的回复。谢谢。

4

2 回答 2

2

您必须确保在构建 APK 时导出您的库。

在 Project properties > Java Build Path > Order and Export => 检查你的库

于 2012-11-15T15:53:01.570 回答
0

您需要在项目首选项中添加库。

于 2012-11-15T15:48:23.297 回答