Unable To Resolve Exception Class: ZXing

╄→尐↘猪︶ㄣ 提交于 2019-12-08 10:32:36

问题


I have a project that runs perfectly fine on newer devices and API levels, however, I'm getting some issues on emulators. When I load up the application on an emulator, I get this issue:

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;

Which then leads to an evident java.lang.VerifyError for the Card class.

The problem is coming up with the WriterException class, but that class is just:

/*
 * 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 dswitkin@google.com (Daniel Switkin)
 */
public final class WriterException extends Exception {

  public WriterException() {
  }

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

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

}

Maybe I'm missing something as to why this is causing an issue on older API levels, but that's the reason why I'm asking this here! I appreciate the collective and mass knowledge at SO.

EDIT:

I tried removing the thrown WriterException by handling it inside a deeper in class. That prevented that issue I was getting as listed above (still not sure why). However, a new issue has arisen!

I think this may have to do with my library not being read properly. I have a User Library with the ZXing core.jar inside of it. The .jar lists every class and will open it all, but I'm getting:

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;

in my warnings now. I'm really stumped with all of this..

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


回答1:


It's nothing to do with WriterException and you should not have to modify the code. The library itself is fine. You can see that actually many classes are missing, probably all of them. You have not actually included the library. Since you say you repackaged it, the problem is there. The classes aren't in the .jar correctly, or maybe you included it as a .jar in a .jar.



来源:https://stackoverflow.com/questions/15035235/unable-to-resolve-exception-class-zxing

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!