Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I make a rather native C++ app with Android?

Tags:

I'm interested in the following features:

  1. Writing an app for Android Market that is written completely in C++ (a port of existing product actually).
  2. Use fast screen-buffer pixel pushing (or rather using OpenGL ES for this).
  3. Grab user input and direct it to C++ code.

Is it legal to write such an app for Market? Is Market policy somehow strict to such things?

like image 366
Hedin Avatar asked Feb 20 '10 06:02

Hedin


People also ask

Can I program with C in Android?

You can add C and C++ code to your Android project by placing the code into a cpp directory in your project module. When you build your project, this code is compiled into a native library that Gradle can package with your app.

Can you make Android apps with Objective C?

"You cannot run Java on iPhone, and you cannot run Objective-C on Android."

Can we make mobile apps using C?

You can build apps for Android, iOS, and Windows devices by using Visual Studio. As you design your app, use tools in Visual Studio to easily add connected services such as Microsoft 365, Azure App Service, and Application Insights. Build your apps by using C# and the . NET Framework, HTML and JavaScript, or C++.


2 Answers

As of NDK r5 with Android 2.3 (Gingerbread) this is possible, although I assume only devices to support natives apps must have Gingerbread on them.

From the native-activity sample:

The Android SDK provides a helper class, NativeActivity, that allows you to write a completely native activity. With a native activity, it is possible to write a completely native application. NativeActivity handles the communication between the Android framework and your native code, so you do not have to subclass it or call its methods. All you need to do is declare your application to be native in your AndroidManifest.xml file and begin creating your native application.

like image 150
tonylo Avatar answered Oct 18 '22 03:10

tonylo


It is really not my cup of tea but there is something called Android NDK (Native Development Kit) to use if you want to write your program in C. Not sure how the C++ compiler support is though.

As far as I know your app can be almost 100% native code but keep in mind that by walking that way you will probably have a hard time supporting the different CPUs out there in Android hardware. If you need to bootstrap the native code so that it is started from java it is probably not a very big problem for you.

I found a few different tutorials when googling for "Android NDK". This one is a very minimalistic Hello World. Obviously you want something much more than a library that returns a string to java but it is a good first start and you will probably have to do all of the things described. Do a search using NDK and Android as keywords and you get a good selection. I see no reason to list them here as such lists tends to be outdated and broken within a year or so.

I guess the official Android Developer site from Google will stay put and be updated on new releases of the platform, it has a link to the current NDK.

like image 34
Fredrik Avatar answered Oct 18 '22 04:10

Fredrik