android how to make native zip application
I would like to create a zip file from files located on the sd card, I have managed to do that using java but I think that the result is too slow, so I thought of going native using the android NDK.
My questions are:
Does anyone know any C/C++ library to zip unzip files that w开发者_运维知识库ill work on android?
How to know if the library will work on android?
Will this make any difference on performance?
With regard to your question "How to know if the library will work on Android" - it depends on the dependencies that the library has. The standard google NDK has very limited C++ support. If it's written in C you're probably OK, but if it's C++ you need to make sure it uses ONLY the following headers/libraries:
- libc (C library) headers
- libm (math library) headers
- JNI interface headers
- libz (Zlib compression) headers
- liblog (Android logging) header
- OpenGL ES 1.1 and OpenGL ES 2.0 (3D graphics libraries) headers
- libjnigraphics (Pixel buffer access) header (for Android 2.2 and above).
- A Minimal set of headers for C++ support
(From homepage)
If you need full C++ support, you will need to use the Crystax NDK.
Be forewarned - the process of cross compilation is Very. Complicated. If you're not extremely comfortable on the command line and with the ins and outs of C compilation, linking, etc., I would look for an alternative solution.
I personally like 7zip, they are open sourced here. You can try compiling this within your app in Android NDK. gzip is also another good option.
Given how core zip files (apk files, jar files) are to android, I'd be very surprised if the java zip file functions aren't using native implementations of the actual algorithms.
Remember the SD card itself is slow compared to ordinary disks.
精彩评论