ZBar - QR Code Scanner, crashing in Android Studio

无人久伴 提交于 2019-12-05 02:09:25

I think, you made mistake in your jars structures. If you want to make jar package from *.so libs you should use that kind of structure:

/lib/armeabi/*.so

It is directory structure example for your library:

lib/
---/armeabi
------/libiconv.so
------/libzbarjni.so

and of course you should rename final package from lib.zip to armeabi.jar. In your case you should repeat this process for armeabi-v7a and x86.

The solution is too complicated. What I did to get it working, was to use the jar files already compiled in the example solution from this example. Copy them to your lib folder and make sure to also add them in the gradle file. However, your line compile fileTree(dir: 'libs', include: '*.jar') should do the trick.

Put the directories armeabi, armeabi-v7a, and x86 in a sub-directory called native-libs under your root project folder. Then add these settings to your build.gradle file:

android {
    // other settings
    sourceSets {
            main {
                jni.srcDirs=[] //to suppress makefiles autogeneration
                jniLibs.srcDirs=['native-libs'] //native *.so in armeabi x86 and mips to include
            }
        }
}

The resulting .apk should have the native libs included now.

You better check if you have the newest possible version of ZBar in dependencies in your app.gradle file. Getting the latest version worked for me and solved all the problems like failing to find libzbarjni.so and libiconv.so

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