user2313423
user2313423

Reputation: 755

Android ZBar Exception only with Jenkins build

I have an android project with a QR scan activity. I use the ZBar library for this: http://sourceforge.net/projects/zbar/files/AndroidSDK/

If the project is built on a PC or Mac with exlipse, the app works fine. If it's build by jenkins (same source from git) the app crashes.

The Exception I get is:

at controller.gui.activity.QRScanActivity.onCreate(Unknown Source)
at android.app.Activity.performCreate(Activity.java:4465)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
at android.app.ActivityThread.access$600(ActivityThread.java:123)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NoSuchFieldError: no field with name='peer' signature='J' in class Lnet/sourceforge/zbar/ImageScanner;
at net.sourceforge.zbar.ImageScanner.init(Native Method)
at net.sourceforge.zbar.ImageScanner.<clinit>(Unknown Source)
... 16 more

I used the demo app for a base.

Is this a Jenkins config problem?

The Zbar library is not just a jar file, it's a C library with jni. So I have a jar file and 3 folders (for different architectures I think) and they have a libiconv.so and a libzbarjni.so files.

Upvotes: 7

Views: 2392

Answers (2)

Muzikant
Muzikant

Reputation: 8090

Add -keep class net.sourceforge.zbar.** { *; } to your proguard config file

Upvotes: 26

jirungaray
jirungaray

Reputation: 1674

I Dont know if you already figured it out, but this is a proguard issue. Seems your JNI classes are not being obfuscated correctly. You might need to change your proguard config to skip ZBar files.

Upvotes: 3

Related Questions