Android: ClassNotFoundException, including ZXing

I know there are a lot of questions. I went through everything, but still I could not solve my problem.

I was asked to expand an existing Android app based on PhoneGap . I checked the sources from the repo and realized that the first developer included the library as dependency in it. I followed the instructions here , building core from ZXing not build.xml for ant .

I read the XZing instructions Getting started , create your own core-2.3.jar , which tried to enable but failed. Same thing with ready deployed core.jar from the page

I included banks in the /libs folder, imported - external jar , nothing worked. I get the following error every time:

 07-24 17:09:47.554: E/AndroidRuntime(8113): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{dev.tesobe.mobilepayment/com.google.zxing.client.android.CaptureActivity}: java.lang.ClassNotFoundException: Didn't find class "com.google.zxing.client.android.CaptureActivity" on path: /data/app/dev.tesobe.mobilepayment-1.apk 07-24 17:09:47.554: E/AndroidRuntime(8113): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2106) 07-24 17:09:47.554: E/AndroidRuntime(8113): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230) 07-24 17:09:47.554: E/AndroidRuntime(8113): at android.app.ActivityThread.access$600(ActivityThread.java:141) 07-24 17:09:47.554: E/AndroidRuntime(8113): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234) 07-24 17:09:47.554: E/AndroidRuntime(8113): at android.os.Handler.dispatchMessage(Handler.java:99) 07-24 17:09:47.554: E/AndroidRuntime(8113): at android.os.Looper.loop(Looper.java:137) 07-24 17:09:47.554: E/AndroidRuntime(8113): at android.app.ActivityThread.main(ActivityThread.java:5041) 07-24 17:09:47.554: E/AndroidRuntime(8113): at java.lang.reflect.Method.invokeNative(Native Method) 07-24 17:09:47.554: E/AndroidRuntime(8113): at java.lang.reflect.Method.invoke(Method.java:511) 07-24 17:09:47.554: E/AndroidRuntime(8113): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 07-24 17:09:47.554: E/AndroidRuntime(8113): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) 07-24 17:09:47.554: E/AndroidRuntime(8113): at dalvik.system.NativeStart.main(Native Method) 07-24 17:09:47.554: E/AndroidRuntime(8113): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.zxing.client.android.CaptureActivity" on path: /data/app/dev.tesobe.mobilepayment-1.apk 07-24 17:09:47.554: E/AndroidRuntime(8113): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65) 07-24 17:09:47.554: E/AndroidRuntime(8113): at java.lang.ClassLoader.loadClass(ClassLoader.java:501) 07-24 17:09:47.554: E/AndroidRuntime(8113): at java.lang.ClassLoader.loadClass(ClassLoader.java:461) 07-24 17:09:47.554: E/AndroidRuntime(8113): at android.app.Instrumentation.newActivity(Instrumentation.java:1054) 07-24 17:09:47.554: E/AndroidRuntime(8113): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097) 

The manifest declaration is as follows:

 <!-- ZXing activities --> <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" android:exported="false"> <intent-filter> <action android:name="com.phonegap.plugins.barcodescanner.SCAN"/> <category android:name="android.intent.category.DEFAULT"/> </intent-filter> </activity> <activity android:name="com.google.zxing.client.android.encode.EncodeActivity" android:label="@string/share_name"> <intent-filter> <action android:name="com.phonegap.plugins.barcodescanner.ENCODE"/> <category android:name="android.intent.category.DEFAULT"/> </intent-filter> </activity> 

So, does anyone have any idea why I cannot enable CaptureActivity ?

+4
source share
2 answers

You must make sure:

  • ZXing library added to libs directory
  • Import ZXing library into properties / build path
  • Provide - and this is an important part - on the Order & Export tab, in which Android private libraries are activated.

As a rule, with the latest Android Eclipse plugins, this whole process is automatic when inserting jar into the libs directory, but there are some problems when adding new libraries to old proyects. Try enabling private Android libraries.

ExtraBall: If you only want to capture barcodes, you can try this Zxing fork with the only indispensable ZXing feature http://code.google.com/p/android-zxinglib/

+4
source

ISSUED QUESTION

Well ... Stupid mistake. In the end, I realized that I did not need to include the XZing Library jar . The guy who started the project included the PhoneGap Barcode Scanner Plugin , which can be found here . Follow the instructions and everything works well ...

0
source

Source: https://habr.com/ru/post/1493234/


All Articles