使用android.mk

时间:2015-09-22 05:57:43

标签: android zbar

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 name with name ='data'signature ='Ljava / lang / Object;'在类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.

感谢任何帮助。 感谢

3 个答案:

答案 0 :(得分:2)

系统构建使用来自:build \ core \ proguard.flags

的proguard文件

如果你必须定义自定义proguard,那么在Android.mk中你需要提到文件路径:LOCAL_PROGUARD_FLAG_FILES:= proguard-project.txt

在proguard-project.txt中:

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

这将解决您的问题..我亲自测试过:)

答案 1 :(得分:0)

尝试用BUILD_MULTI_PREBUILT替换LOCAL_SRC_FILES。

答案 2 :(得分:0)

我找到了问题的答案。添加带有false值的LOCAL_PROGUARD_ENABLED标志解决了我的问题。 添加此项将导致不优化jar文件,从而将数据变量保留在Image类中。 我希望这对面临类似问题的人有所帮助。 谢谢