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

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.

Related

Android studio c++ ndk support

One of my friends suggested to use c++ support in Android studio in order to hide passwords. I have found tons of tutorials how to get started with ndk in android. But they are all outdated(2015) and everytime I try to use c++ in any way, Android studio crashes. Is there any way to do it in a simpler way now?
P.S./ I want to get rid of experimental plugin that every one uses.
Little off the question, storing passwords in the native layer does not ensure complete safety. A good hacker can get that as well. It is just that you add another additional layer so one has to dig deeper

Image processing on Android Platform

I am new to android platform and have to do by B Tech project on this. I have to do product recognition and then process them. So, I need to do some serious coding on implementation of Image Processing on Android platform.
For this, I would require :-
Through understanding of Android programming
Setting up the environment for image processing on Android.
Finally, an emulator to debug my codes
So, I need suggestions for all of the above, like, what book I should go through for learning Android , what emulators I should use and can I use openCV libraries in my android application.
Regrading emulators, I have heard, that they are pretty slow and have lots of bugs. They keep on hanging. So, should I have an Android mobile then ?
Please comment, if, you are unclear about my question.
PS: I posted the same question here, but got no replies. So, posted it again.
Thanks !!
There are a lot of books out there, CommonsWare is a pretty good place to start for the basics, he has office hours (where you can ask questions) and comments on here quite a lot.
There is only one emulator as far as I know, most people use eclipse for their environment and it's fairly well integrated with the android tool set, but there are a few others, as well as command line tools if your prefer those everything you need for android development is here other than eclipse which is here
In regards to image processing I assume you mean image matching and yes there is an openCV for android there are also some commercial offerings if you don't want to try and sort through openCV
If you are going to be using a camera to do image matching then the emulator is not a great choice unless you want to be restricted to using it with a webcam (which is a pain to get working) you will still work a lot with the emulator though.

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.

Is Titanium 1.8 finally free from the memory starvation issue from release 1.6 and 1.7

Hi there Im new to mobile application development. I had developed Android apps using Java and is just starting to get the hang of Cocoa Touch and Objective C. Now I am curious on mobile web application development to create cross platform/device applications which would at least run on Android and iOS(Apple devices: iphone, ipad). I tried Titanium and developing applications with this framework seems very promising. Although it is very powerful, popular, mature, documented and very easy to learn I had doubts investing time and to commit on using this framework for my projects after reading this blog which many Titanium users seems to agree with Why you should stay away from appcelerators titanium.
It seems that release v1.6 sdk and v1.7 sdk have the issue which they describe, the negative comments stopped right after the v1.8 sdk release was out.
My question is, is Titanium v1.8 sdk free from the memory starvation issue and other issues which were discussed on the blog post?
Would you personally recommend this for production use? And by the way I am using the 1.0.7.201112152014 Titanium build does this use the 1.8 sdk? Thanks in advance.
Take a close look at the progress of comments. It starts from people agreeing with him, and in the end everyone disagrees.
You can select the SDK you wish in the tiapp.xml editor, which is embedded in Titanium Studio. You should indeed use 1.8.x
The platform isn't, and probably never will be, memory issue free. But it also depends on how you build your app.
Stay away as much as you can from includes. And also stay away from creating a window/view/etc. with a file as url in it, this causes most memory issues because it's in a different space.
If you code well, you can use it perfectly without any issues.
Blog post author here. I don't fully agree with Topener - go ahead and read the comments yourself, it's just not true that "in the end everyone disagrees".
For what's worth: my experience is related to version 1.6.2. I've talked to people working with trunk and they told me that the memory issues are far from being resolved.
The only approach that seems to work is, as mentioned in the comments, the Tweetanium approach. But beware, that's not "if you code well". It's "if you code the way Titanium likes". If you take a look at Tweetanium (I suggest you to do it no matter what you decide to do in the end) you'll see that it has a very specific way to deal with architecture. If you follow that path, you should be good. If you think that the way Tweetanium is structured is good for you application, go for it. Be wary though, because (at least in what I consider to be complex) Tweetanium is not very complex, and with growing complexity I found that their approach is difficult to maintain. Again, evaluate for yourself.
Then there's the Android issue. Android support is far from optimal - Wunderlist decided to rewrite their Android version in native, I myself have had huge problems in making anything even remotely complex in iOS working decently on Android. If you need to support only iOS it's alright but, if that's the case, I don't see why you shouldn't write the app directly in Objective-C... considering also the (unavoidable) delay/mismatch between the Titanium and the iOS SDK.
Just my 2c. I suggest you not to take the decision lightly - it costed us a lot.

Customizing Android

I want to use Android for a system I have in order to use it as an embedded system that would run a specific application (which runs in chrome browser). However, this will not use Android in ordinary way, but rather hack around it so that libraries like OpenCV and packages like Chromium can be installed on the Android's Linux kernel. In addition, I would also need to figure out a way that would allow a USB camera to be supported.
I have done some research on this, but I am getting nowhere. Would somebody recommend resources that are relevant to this issue, or suggestions on how to approach it? Your feedback would be much appreciated.
Edit1: I am not intending for this question to be too broad. I only want to get more ideas on how you add libraries like OpenCV to Android, and whether there is a way to install the chrome browser as well.
Edit2: the Android system is on the Snapdragon platform.
Both Chromium and OpenCV can be built on Linux, have you tried compiling them from source on Android and failed? What error did you get? Here's a link for cross-compiling Chrome for ARM processors:
http://code.google.com/p/chromium/wiki/LinuxChromiumArm
I would use http://www.android-x86.org/ first and see if it works there before trying to run it on ARM so that you can fail faster if it doesn't work.
You might want to spend some time with ROM hackers to get more insight. Ideally, you want to find some people who are doing something similar so you can work with them. Take a look at:
http://forum.cyanogenmod.com/
http://forum.xda-developers.com/
A lot of what those guys are doing does not apply to what you are looking for, but they do get much deeper into the OS than most programmers. You might get lucky, and not have to modify the Android source code yourself as thinksteep mentions.

Categories

Resources