Snappy compression on Android - android

I am currently using Gzip to compress attachments in Couchbase on Android. Recently bumped into Snappy, that seems to be an efficient solution, so decided to use Snappy instead of GZip.
Snappy github - https://github.com/xerial/snappy-java
But what I am confused is how to use the Snappy library in Android. I downloaded the latest version of snappy (1.1.2.1) from http://central.maven.org/maven2/org/xerial/snappy/snappy-java/1.1.2.1/ and dropped it in the libs folder of the Android project. I now can reference the Snappy class methods in my Android source code, which made me think that everything was going great so far. Now when I run the app, I get the following error when I call Snappy.compress(byte[] data) -
org.xerial.snappy.SnappyError: [FAILED_TO_LOAD_NATIVE_LIBRARY] no native library is found for os.name=Linux and os.arch=aarch64
org.xerial.snappy.SnappyLoader.findNativeLibrary(SnappyLoader.java:331)
org.xerial.snappy.SnappyLoader.loadNativeLibrary(SnappyLoader.java:171)
org.xerial.snappy.SnappyLoader.load(SnappyLoader.java:152)
org.xerial.snappy.Snappy.<clinit>(Snappy.java:47)
I created a sample java class to test Snappy, and it works great.
So, from my understanding, its missing some native libraries for the Linux kernel, but even from the description on the github page, cannot figure out a way to build the jar file that I can use on Android.
Any help would be greatly appreciated.
Thanks

Looks like Linux/aarch64 for Snappy is in the works, but not yet released:
https://github.com/xerial/snappy-java/issues/134

You could give a shot at https://github.com/dain/snappy. It's a pure java port so no need for native libs.

Related

Android, how to use phone's SQLite from C++?

I've developed a SQLite wrapper for React Native using C++. The easiest way to get it working was to include the SQLite amalgamation in the sources. This however increases the bundle size significantly. So I want to give the users the option to use the phone's embedded SQLite version.
The iOS version is working (I exclude the sources if an environment flag is present). Android seems a lot more complicated though. Most of the answers I find on google recommend using the amalgamation path. It seems however it is possible to use the phone's SQLite version (it comes by default with the NDK).
I'm currently compiling the amalgamation via CMake.
I'm an Android noobie, would someone explain it like I'm 5 how can I link/access the SQLite headers from my NDK C++ code? Maybe I should just leave the sqlite.h header file and it will link with the phone's version?
EDIT 1: It seems leaving the header file only, does not work. I've also ran into this Hacker News thread. Some of the comments seem to suggest it is not really possible to access things like curl/sqlite/etc from the NDK code. Any thoughts?
Thanks a lot!
Edit 2: I found a link that might work https://blog.katastros.com/a?ID=00200-fd6cd935-b779-4f44-9b4c-efad582167e1
After much fumbling around I've come to the conclusion there is no way to achieve linking the phones sqlite via c++. It is also probably best so, old android versions have outdated versions, vendors also modify the running sqlite versions and they are full of old bugs and broken stuff.

How to implement herumi/mcl library into my Android project?

I would like to use herumi/mcl library in my Android project. I posted a question on Author's forum and he replied with these two solutions:
1. https://github.com/herumi/bls-eth-go-binary/ provides a static library for Android, which contains mcl functions. You can use them through gomobile .
2. https://github.com/herumi/mcl/tree/master/ffi/java provides JNI of mcl. If you can build libmcljava.so for Android by cross-compile, then you can use mcl such as https://github.com/herumi/mcl/blob/master/ffi/java/MclTest.java.
I think that great solution for me is the second Option, but i absolutely dont know how. I am using Android NDK to call C code to my app, but thats all i know.
I am looking for some fresh tutorial or something like step-by-step, what would help me to use this library in my Android project. I am working on Windows OS.

TarsosDSP with Android - no relevant source code

I follow up on this article: TarsosDSP with Android
I am trying to implement an android application that reads mp3 files and processes them using WEKA.
The TarsosDSP seems to be a good step in the right direction, especially since the Berkley guys seems to have implemented a fork with android.
When I tried downloading their source code here: TarsosDSPAndroid Source Code
I still found a lot of references to javax.sound, which is kind of counter-productive.
So is something mixed up with their uploaded source code or am I looking in the wrong place?
Perhaps some background to what I am trying to accomplish overall:
I am writing an Android App that will read the entire mp3 library, and using WEKA and pre-loaded test-groups will classify each song to appropriate genre.
The part of reading the mp3 library is all done and so is the classification using WEKA, now I am stuck in joining them up - What seemed to be working fine using jAudio in a java project doesn't work for android because of the dependency in javax.sound, so I am trying to bypass that using a different library that works for android.
Thanks in advance!
-Alex
Version 2.0 of TarsosDSP supports Android out of the box. There are no more dependencies on javax.sound.*. This makes it a lot more easy to work with on Android. There is even an TarsosDSP Android jar file that can be included in your project directly.

Is there a (somewhat high level) C++ library to create pdf documents that runs on iOS and Android?

I need a C++ library that runs on Android and iOS which can be used to create PDF documents.
So far I have found libHaru:
libHaru is a free, cross platform, open source library for generating PDF files.
The library seems fine and I already found a working example on how to use it with iOS.
But I would like to have a library less "low level", because in libHaru you have to manually create new pages, line breaks etc. So the question is if someone can advice me any C++ library which can run on Android and iOS and is a little bit more high level.
As a bonus: It would be great, if that library is also free (as in freedom) or at least free to use.
Edit: I have tried Qt and it is rather clumsy to use in such an early development stage (regarding iOS and Android development). I would appreciate a stable library with good documentation provided.
You can use Qt for that. The class you would be looking for is QPdfWriter The nice thing about it is, that as you draw onto that thingy, you can replace the QPdfWriter with different kinds of QPaintDevices, like QWidget or QImage and so forth. It's very generic and high level, but Qt is also quite big.

Porting Visual C/C++ to Android

In my recently started internship (I'm studying computer science), I have to port a somewhat big existing Project to Android. It is a Visual C/C++ Project which in the end should run on Android using of course the NDK. The problem is that I don't know a thing about porting software, since this is not covered in my studies...
I had a few days to get to know the project I will be working with a little.
A few words about the complexity:
It is a Visual Studio solution which consists of 28 projects of which most are kind of big...
And now I need to develop a concept for porting it to Android, and this is why I'm writing this. I have absolutely no idea know where to start, also I don't know how to get to a concept for porting it. I tried searching online for some stuff or for some books covering this, but I found nothing.
Of course I know, that basically I have to remove everything that is Visual/Windows specific and replace it with appropriate Android/Linux functions or implement something new if there is nothing corresponding on Android.
But since this project is somewhat huge, I can't just try to compile it with the correct compiler and work through the error messages, this will lead to nowhere, I guess...
So now my actual question:
Is anybody experienced about this or something similar and can give some tips how to start with it? As I said, I first need a concept. Something more general about how to start and deal with porting a software project of this size is also very welcome, since I don't know nothing about it...
I think that you're approaching the whole matter in the wrong way. There are several tools that will allow you to compile C# and visual C++ and other visual languages from their respected IDEs to the android platform. For example there is mono for android . Mono is a plugin for visual studio which helps you create android projects using visual studio and .net technologies. I think you should focus your research on tools like this because changing all of the code manually is nearly impossible and too time consuming. Here is a page that will help you get started with mono for android. Good luck.
See this answer Android NDK with Visual Studio.
Personally I don't use this, but It seems to be a nice solution to your problem.
Like you, in the past, we had to port a big Visual C++ library project to Android, we proceeded in this way:
Try to compile the main library interface (by creating the relative Android.mk)
By using linking errors, you should guess other projects to be compiled and create the mks for them
Cycle until you have no more linking errors.
You didn't tell about the source code size of the project (how many thousands of lines of source code).
If the code size is big enough (e.g. at least 100 KLOC), you could consider customizing the GCC compiler (assuming a recent 4.6 or 4.7 version), perhaps using MELT (a high level domain specific language to extend GCC), or painfully coding in C a GCC plugin. This GCC customizing approach is worthwhile only for large code bases (you'll need several days to master GCC internals).
On the other hand, many well designed applications may have packaged their operating system functions inside a well defined interface and library. You might consider porting your application to Qt or some other cross-platform library.
We need more details about your project to help you more.

Categories

Resources