2013-02-22 57 views
0

我有一個項目在新設備和API級別上運行得非常好,但是,我在仿真器上遇到了一些問題。當我在模擬器上加載了程序,我碰到這個問題:無法解決異常類:ZXing

02-22 18:36:11.584: W/dalvikvm(652): VFY: unable to resolve exception class 872 (Lcom/google/zxing/WriterException;) 
02-22 18:36:11.584: W/dalvikvm(652): VFY: unable to find exception handler at addr 0x7da 
02-22 18:36:11.584: W/dalvikvm(652): VFY: rejected Lcom/example/myapp/Card;.getFrontView (Landroid/content/Context;)Landroid/widget/LinearLayout; 
02-22 18:36:11.584: W/dalvikvm(652): VFY: rejecting opcode 0x0d at 0x07da 
02-22 18:36:11.584: W/dalvikvm(652): VFY: rejected Lcom/example/myapp/Card;.getFrontView (Landroid/content/Context;)Landroid/widget/LinearLayout; 
02-22 18:36:11.584: W/dalvikvm(652): Verifier rejected class Lcom/example/myapp/Card; 

然後導致一個明顯java.lang.VerifyErrorCard類。

的問題想出了WriterException類,但這個類就是:

/* 
* Copyright 2008 ZXing authors 
* 
* Licensed under the Apache License, Version 2.0 (the "License"); 
* you may not use this file except in compliance with the License. 
* You may obtain a copy of the License at 
* 
*  http://www.apache.org/licenses/LICENSE-2.0 
* 
* Unless required by applicable law or agreed to in writing, software 
* distributed under the License is distributed on an "AS IS" BASIS, 
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
* See the License for the specific language governing permissions and 
* limitations under the License. 
*/ 

package com.google.zxing; 

/** 
* A base class which covers the range of exceptions which may occur when encoding a barcode using 
* the Writer framework. 
* 
* @author [email protected] (Daniel Switkin) 
*/ 
public final class WriterException extends Exception { 

    public WriterException() { 
    } 

    public WriterException(String message) { 
    super(message); 
    } 

    public WriterException(Throwable cause) { 
    super(cause); 
    } 

} 

也許我失去了一些東西,爲什麼這導致在舊API級別的問題,但是這就是原因爲什麼我在這裏問這個問題!我讚賞SO的集體和大衆知識。

編輯:

我試圖通過處理這裏面上課更深去除拋出WriterException。這阻止了我上面列出的問題(仍然不知道爲什麼)。但是,出現了一個新問題!

我認爲這可能與我的圖書館沒有正確閱讀有關。我有一個用戶庫,裏面有ZXing core.jar。現在

02-22 18:56:49.564: W/dalvikvm(688): VFY: unable to find class referenced in signature (Lcom/google/zxing/BarcodeFormat;) 
02-22 18:56:49.604: E/dalvikvm(688): Could not find class 'com.google.zxing.EncodeHintType', referenced from method Barcode.BarcodeGenerator.encodeAsBitmap 
02-22 18:56:49.604: W/dalvikvm(688): VFY: unable to resolve const-class 869 (Lcom/google/zxing/EncodeHintType;) in LBarcode/BarcodeGenerator; 
02-22 18:56:49.604: D/dalvikvm(688): VFY: replacing opcode 0x1c at 0x0011 
02-22 18:56:49.604: E/dalvikvm(688): Could not find class 'com.google.zxing.MultiFormatWriter', referenced from method Barcode.BarcodeGenerator.encodeAsBitmap 
02-22 18:56:49.604: W/dalvikvm(688): VFY: unable to resolve new-instance 870 (Lcom/google/zxing/MultiFormatWriter;) in LBarcode/BarcodeGenerator; 
在我警告

:將.jar列出每一個類,並會打開這一切,但我得到。我真的有了這一切難倒..

Here is a screenshot of the User Library, called ZXing, that I have added to my project's Java Build Path > Libraries.

+0

@DigCamara我聲明:android:minSdkVersion =「8」和android:targetSdkVersion =「17」 – RileyE 2013-02-23 00:04:19

+0

@RileyE你在哪裏放置了外部jar庫? – 2013-02-23 01:45:54

+0

SDK級別與此無關。 – 2013-02-23 07:18:23

回答

0

這無關WriterException,你不應該修改代碼。圖書館本身很好。你可以看到實際上有很多類都丟失了,可能都是這些類。你還沒有包括圖書館。既然你說你重新包裝它,問題就在那裏。這些類不在.jar中,或者您可以將其作爲.jar包含在.jar中。

+0

你可能知道最好的(創建了庫),但問題可能源於他在模擬器中使用庫嗎?我的猜測是,因爲他在模擬器中使用它,它沒有找到它正在尋找的硬件設備和/或軟件。 – DigCamara 2013-02-25 15:39:30

+0

對不起,回覆遲了,但我錯過了你的回覆。我已經將該庫作爲用戶庫包含在內,並且這些文件都列在了我的ADT/Eclipse菜單中。我在包含ZXing core.jar及其內容的用戶庫的原始文章中包含了屏幕截圖。也許它不能是一個用戶庫?我不知道爲什麼它會這樣做。 – RileyE 2013-02-25 17:57:59

+0

哇。我才意識到你是ZXing的主要作者。所以,我所做的是將核心項目構建到core.jar中,然後將其添加到乾淨的用戶庫中。正如你所看到的,我將所有的文件列在ADT/Eclipse中的庫下,所以我認爲它們都在那裏並且應該可以工作。當我將庫core.jar路徑從本地目錄移動到Dropbox目錄時,問題最初開始。圖書館的路徑是正確的,一切似乎都是按順序的。這就是爲什麼我很困惑。 – RileyE 2013-02-25 18:11:19