我使用Biggu條碼庫。Android條碼掃描器
打包庫已使用演示和示例應用程序列出了所有內容。
但我沒有得到任何類定義發現錯誤
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;
}
}
Android清單文件
<?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" />
竭盡所能來設定權 任何人都可以讓我知道什麼可能是錯誤的在代碼中。期待您的回覆。謝謝。
謝謝。這是一個單獨的項目,沒有庫項目..我在Java構建路徑的庫中引用jar文件'biggu_scanner-1.1.0.jar'。 – Mukunda
您是否嘗試清理該項目? – alejandrocordon