Pure Native App or Java Shell for Android Market?
Here is a recent question Charles Wilde received about porting native code to Android:
Q: I just read your PDF book on native development for Android and have some questions about deploying applications on Android devices. Are you able to sign and deploy a purely native application to the Android Market and will devices even allow a native application to be executed? If not, can you create a traditional Java shell for your pure native application and execute it in a new process from Java using the java.lang.Runtime.exec() function?
A: You might be able to deploy a pure native C++ application on the Android store, but there probably some hurdles there, related to the application manifest and signing.
Even if you could get around the hurdles, to me that seems to be a difficult way to accomplish a result. A better way, as you suggested, is with a traditional Java shell. You could attempt to launch the C++ app in a new process, but that might run counter to various security constraints in deployed phones.
As you suggest, you might use java.lang.Runtime.exec(). Note that this may work only with native applications (i.e. those included with the ported Android OS). You may not be able to use java.lang.Runtime.exec() with a pure C/C++ app you create, since the phone’s security may block you from deploying your app into the folder where java.lang.Runtime.exec() looks for native apps. I have not attempted to start a pure C/C++ app using java.lang.Runtime.exec(), so I am speculating here about the possible results.
A better tack, in my view, is to deploy a hybrid app, a Java shell with perhaps an included GUI, and C/C++ code as shared libraries. This arrangement is known to work and provides you with the power of Java classes for GUI operations, and the ability to leverage the power of C/C++ in a way that is compatible with the rest of Android.
If you are doing your own custom port of the full Android OS onto your device, then you can create a pure C/C++ app to be included in the final Android OS build, and the restrictions mentioned above go away. But for general deployment of apps on Android, it will probably be easier to use the hybrid approach.
If you have not yet ported your C/C++ app to Android, note that C++ exceptions are not supported, and the STL standard library templates are not included. You can get a third party STL library from www.stlport.org, but C++ exceptions requires Android OS and runtime support that simply does not exist.
With 20+ years as a top software and firmware developer, Charles Wilde has acquired a combination of proven business smarts, mobile development skills and device engineering expertise that is hard to match. Charles is available to consult with you and your team about native code development in Android, Windows Mobile or Windows CE. Wilde is author of the e-book, Porting Native Code to Android and receives a royalty from the sale of the ebook. He can be reached at AtonMail ( at ) aton (dot)com. © 2010 Aton International, Inc.
Related posts
- Android Software Development Tools - What Do I Need?
- Android Native Libraries for Java Applications
- Porting Native Code to Android: From Business Case to Coding
- Android Native Development on Ubuntu 9.04 (Jaunty Jackalope)
- Developing An Android Mobile Application
No Comments
No comments yet.
Sorry, the comment form is closed at this time.
