Zxing CaptureActivity - 启动活动时崩溃

时间:2013-04-16 13:34:28

标签: android zxing

我正在尝试将Zxing的QR阅读功能整合到一个独立的应用程序中,并且一直在使用这个非常有用的指南http://damianflannery.wordpress.com/2011/06/13/integrate-zxing-barcode-scanner-into-your-android-app-natively-using-eclipse/以及这些指针Integrating the ZXing library directly into my Android application但是在构建了库之后,并按照所有步骤按下按钮启动此活动,它仍然无法正常工作。该应用程序启动,但按下按钮后,它会崩溃。

activity_main.html

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:onClick="buttPress"
        android:text="@string/button_send"
        android:textColor="#FFFFFF"
        />

</RelativeLayout>

MainActivity.java

package se.mydomain.myapp;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    public void buttPress(View view) {
        Intent intent = new Intent("com.google.zxing.client.android.SCAN");
        intent.putExtra("SCAN_MODE", "QR_CODE_MODE");
        startActivityForResult(intent, 0);
    }

    public void onActivityResult(int requestCode, int resultCode, Intent intent) {
           if (requestCode == 0) {
              if (resultCode == RESULT_OK) {
                 String contents = intent.getStringExtra("SCAN_RESULT");
                 String format = intent.getStringExtra("SCAN_RESULT_FORMAT");
                 // Handle successful scan
              } else if (resultCode == RESULT_CANCELED) {
                 // Handle cancel
              }
           }
        }

}

的Manifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="se.mydomain.myapp"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="10"
        android:targetSdkVersion="17" />

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

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="se.mydomain.myapp.MainActivity"
            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="com.google.zxing.client.android.CaptureActivity"
   android:screenOrientation="landscape"
   android:configChanges="orientation|keyboardHidden"
   android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
   android:windowSoftInputMode="stateAlwaysHidden">
   <intent-filter>
      <action android:name="android.intent.action.MAIN"/>
      <category android:name="android.intent.category.DEFAULT"/>
   </intent-filter>
   <intent-filter>
      <action android:name="com.google.zxing.client.android.SCAN"/>
      <category android:name="android.intent.category.DEFAULT"/>
    </intent-filter>
</activity>
    </application>



</manifest>

这是logcat在启动并按下按钮时的输出。我错过了一些明显的东西吗?在模拟和在手机上运行时都会发生这种情况,顺便说一句。

04-16 13:31:58.313: D/gralloc_goldfish(1359): Emulator without GPU emulation detected.
04-16 13:32:13.034: I/Choreographer(1359): Skipped 82 frames!  The application may be doing too much work on its main thread.
04-16 13:32:13.093: W/dalvikvm(1359): VFY: unable to resolve static field 872 (ISSUE_NUMBER) in Lcom/google/zxing/ResultMetadataType;
04-16 13:32:13.103: D/dalvikvm(1359): VFY: replacing opcode 0x62 at 0x0017
04-16 13:32:13.103: W/dalvikvm(1359): VFY: unable to find class referenced in signature (Lcom/google/zxing/Result;)
04-16 13:32:13.133: W/dalvikvm(1359): VFY: unable to find class referenced in signature (Lcom/google/zxing/ResultPoint;)
04-16 13:32:13.133: W/dalvikvm(1359): VFY: unable to find class referenced in signature (Lcom/google/zxing/ResultPoint;)
04-16 13:32:13.133: I/dalvikvm(1359): Could not find method com.google.zxing.ResultPoint.getX, referenced from method com.google.zxing.client.android.CaptureActivity.drawLine
04-16 13:32:13.143: W/dalvikvm(1359): VFY: unable to resolve virtual method 3648: Lcom/google/zxing/ResultPoint;.getX ()F
04-16 13:32:13.143: D/dalvikvm(1359): VFY: replacing opcode 0x6e at 0x0000
04-16 13:32:13.143: W/dalvikvm(1359): VFY: unable to find class referenced in signature (Lcom/google/zxing/Result;)
04-16 13:32:13.175: I/dalvikvm(1359): Could not find method com.google.zxing.Result.getResultPoints, referenced from method com.google.zxing.client.android.CaptureActivity.drawResultPoints
04-16 13:32:13.175: W/dalvikvm(1359): VFY: unable to resolve virtual method 3644: Lcom/google/zxing/Result;.getResultPoints ()[Lcom/google/zxing/ResultPoint;
04-16 13:32:13.183: D/dalvikvm(1359): VFY: replacing opcode 0x6e at 0x0003
04-16 13:32:13.183: W/dalvikvm(1359): VFY: unable to find class referenced in signature (Lcom/google/zxing/Result;)
04-16 13:32:13.224: I/dalvikvm(1359): Could not find method com.google.zxing.Result.toString, referenced from method com.google.zxing.client.android.CaptureActivity.handleDecodeExternally
04-16 13:32:13.224: W/dalvikvm(1359): VFY: unable to resolve virtual method 3647: Lcom/google/zxing/Result;.toString ()Ljava/lang/String;
04-16 13:32:13.224: D/dalvikvm(1359): VFY: replacing opcode 0x74 at 0x007d
04-16 13:32:13.253: I/dalvikvm(1359): Could not find method com.google.zxing.Result.getText, referenced from method com.google.zxing.client.android.CaptureActivity.handleDecodeExternally
04-16 13:32:13.253: W/dalvikvm(1359): VFY: unable to resolve virtual method 3645: Lcom/google/zxing/Result;.getText ()Ljava/lang/String;
04-16 13:32:13.264: D/dalvikvm(1359): VFY: replacing opcode 0x74 at 0x01c0
04-16 13:32:13.264: W/dalvikvm(1359): VFY: unable to find class referenced in signature (Lcom/google/zxing/Result;)
04-16 13:32:13.284: I/dalvikvm(1359): Could not find method com.google.zxing.Result.getBarcodeFormat, referenced from method com.google.zxing.client.android.CaptureActivity.handleDecodeInternally
04-16 13:32:13.284: W/dalvikvm(1359): VFY: unable to resolve virtual method 3641: Lcom/google/zxing/Result;.getBarcodeFormat ()Lcom/google/zxing/BarcodeFormat;
04-16 13:32:13.284: D/dalvikvm(1359): VFY: replacing opcode 0x74 at 0x004c
04-16 13:32:13.324: W/dalvikvm(1359): VFY: unable to find class referenced in signature (Lcom/google/zxing/Result;)
04-16 13:32:13.354: W/dalvikvm(1359): VFY: unable to find class referenced in signature (Lcom/google/zxing/Result;)
04-16 13:32:13.364: W/dalvikvm(1359): VFY: unable to find class referenced in signature (Lcom/google/zxing/Result;)
04-16 13:32:13.384: W/dalvikvm(1359): VFY: unable to find class referenced in signature (Lcom/google/zxing/Result;)
04-16 13:32:13.384: W/dalvikvm(1359): VFY: unable to find class referenced in signature (Lcom/google/zxing/Result;)
04-16 13:32:13.394: W/dalvikvm(1359): VFY: unable to find class referenced in signature (Lcom/google/zxing/Result;)
04-16 13:32:13.394: W/dalvikvm(1359): VFY: unable to find class referenced in signature (Lcom/google/zxing/Result;)
04-16 13:32:13.414: W/dalvikvm(1359): VFY: unable to find class referenced in signature (Lcom/google/zxing/Result;)
04-16 13:32:13.454: W/dalvikvm(1359): VFY: unable to find class referenced in signature (Lcom/google/zxing/Result;)
04-16 13:32:13.454: W/dalvikvm(1359): VFY: unable to find class referenced in signature (Lcom/google/zxing/Result;)
04-16 13:32:13.484: I/dalvikvm(1359): Could not find method com.google.zxing.Result.getText, referenced from method com.google.zxing.client.android.CaptureActivity.handleDecode
04-16 13:32:13.494: W/dalvikvm(1359): VFY: unable to resolve virtual method 3645: Lcom/google/zxing/Result;.getText ()Ljava/lang/String;
04-16 13:32:13.494: D/dalvikvm(1359): VFY: replacing opcode 0x6e at 0x0068
04-16 13:32:13.504: W/dalvikvm(1359): VFY: unable to find class referenced in signature (Lcom/google/zxing/Result;)
04-16 13:32:13.504: W/dalvikvm(1359): VFY: unable to find class referenced in signature (Lcom/google/zxing/Result;)
04-16 13:32:13.524: W/dalvikvm(1359): VFY: unable to find class referenced in signature (Lcom/google/zxing/Result;)
04-16 13:32:13.574: W/dalvikvm(1359): Exception Ljava/lang/NoClassDefFoundError; thrown while initializing Lcom/google/zxing/client/android/CaptureActivity;
04-16 13:32:13.584: W/dalvikvm(1359): Class init failed in newInstance call (Lcom/google/zxing/client/android/CaptureActivity;)
04-16 13:32:13.584: D/AndroidRuntime(1359): Shutting down VM
04-16 13:32:13.594: W/dalvikvm(1359): threadid=1: thread exiting with uncaught exception (group=0x40a71930)
04-16 13:32:13.664: E/AndroidRuntime(1359): FATAL EXCEPTION: main
04-16 13:32:13.664: E/AndroidRuntime(1359): java.lang.ExceptionInInitializerError
04-16 13:32:13.664: E/AndroidRuntime(1359):     at java.lang.Class.newInstanceImpl(Native Method)
04-16 13:32:13.664: E/AndroidRuntime(1359):     at java.lang.Class.newInstance(Class.java:1319)
04-16 13:32:13.664: E/AndroidRuntime(1359):     at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
04-16 13:32:13.664: E/AndroidRuntime(1359):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
04-16 13:32:13.664: E/AndroidRuntime(1359):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
04-16 13:32:13.664: E/AndroidRuntime(1359):     at android.app.ActivityThread.access$600(ActivityThread.java:141)
04-16 13:32:13.664: E/AndroidRuntime(1359):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
04-16 13:32:13.664: E/AndroidRuntime(1359):     at android.os.Handler.dispatchMessage(Handler.java:99)
04-16 13:32:13.664: E/AndroidRuntime(1359):     at android.os.Looper.loop(Looper.java:137)
04-16 13:32:13.664: E/AndroidRuntime(1359):     at android.app.ActivityThread.main(ActivityThread.java:5041)
04-16 13:32:13.664: E/AndroidRuntime(1359):     at java.lang.reflect.Method.invokeNative(Native Method)
04-16 13:32:13.664: E/AndroidRuntime(1359):     at java.lang.reflect.Method.invoke(Method.java:511)
04-16 13:32:13.664: E/AndroidRuntime(1359):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
04-16 13:32:13.664: E/AndroidRuntime(1359):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
04-16 13:32:13.664: E/AndroidRuntime(1359):     at dalvik.system.NativeStart.main(Native Method)
04-16 13:32:13.664: E/AndroidRuntime(1359): Caused by: java.lang.NoClassDefFoundError: com.google.zxing.ResultMetadataType
04-16 13:32:13.664: E/AndroidRuntime(1359):     at com.google.zxing.client.android.CaptureActivity.<clinit>(CaptureActivity.java:101)
04-16 13:32:13.664: E/AndroidRuntime(1359):     ... 15 more
04-16 13:32:19.034: I/Process(1359): Sending signal. PID: 1359 SIG: 9

0 个答案:

没有答案
相关问题