rahul ahuja
rahul ahuja

Reputation: 13

runtime crash using with zbar.jar while building android system app using android.mk

Hi I am trying to build an system application in android build system which uses <zbar.jar> file" and "armeabi-v7a\libiconv.so" ,"armeabi-v7a\libzbarjni.so libs".

I get error as

09-21 21:14:32.614: E/AndroidRuntime(5217): java.lang.NoSuchFieldError: no field with name='data' signature='Ljava/lang/Object;' in class Lnet/sourceforge/zbar/Image;

09-21 21:14:32.614: E/AndroidRuntime(5217): at net.sourceforge.zbar.Image.init(Native Method)

09-21 21:14:32.614: E/AndroidRuntime(5217): at net.sourceforge.zbar.Image.(Unknown Source)

I have added dependencies in android.mk as below:

LOCAL_STATIC_JAVA_LIBRARIES := libzbar
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES += libzbar:libs/zbar.jar

include $(CLEAR_VARS)
LOCAL_MODULE        := libiconv
LOCAL_MODULE_CLASS  := SHARED_LIBRARIES
LOCAL_MODULE_SUFFIX := .so
LOCAL_MODULE_TAGS   := optional
LOCAL_SRC_FILES     := libiconv.so
include $(BUILD_PREBUILT)

include $(CLEAR_VARS)
LOCAL_MODULE        := libzbarjni
LOCAL_MODULE_CLASS  := SHARED_LIBRARIES
LOCAL_MODULE_SUFFIX := .so
LOCAL_MODULE_TAGS   := optional
LOCAL_SRC_FILES     := libzbarjni.so
include $(BUILD_PREBUILT)

i have also enabled 
"proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt" line in project.properties and 
added "-keep class net.sourceforge.zbar.** { *; }" in progaurd.cfg file.

Any help is appreciated. Thanks

Upvotes: 0

Views: 292

Answers (3)

Nishant Virmani
Nishant Virmani

Reputation: 215

System builds use proguard file from: build\core\proguard.flags

If you have to define custom proguard, then in Android.mk you need to mention the file path: LOCAL_PROGUARD_FLAG_FILES := proguard-project.txt

And in the proguard-project.txt :

-keep class net.sourceforge.zbar.** { *; }

This will solve your problem .. I have personally tested :)

Upvotes: 3

rahul ahuja
rahul ahuja

Reputation: 13

I found the answer to my question. adding the LOCAL_PROGUARD_ENABLED flag with false value solved my problem. adding this this will cause not to optimize the jar file and hence keep the data variable in Image class. i hope it will be helpful for someone facing similar problem. thanks

Upvotes: 0

Nikita
Nikita

Reputation: 77

Try replacing LOCAL_SRC_FILES with BUILD_MULTI_PREBUILT.

Upvotes: 0

Related Questions