24

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?

avakar
  • 32,009
  • 9
  • 68
  • 103
Hedin
  • 630
  • 3
  • 8
  • 19

6 Answers6

15

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.

tonylo
  • 3,311
  • 3
  • 28
  • 27
8

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.

Fredrik
  • 5,759
  • 2
  • 26
  • 32
  • If I had to guess, it's because you suggested Gooling for a string rather than providing a direct link to the project. Sometimes people want to be picky. +1 for the link you did provide, though. It's quite the thorough walkthrough to setting up a development environment, not just a short bit of code. – Conspicuous Compiler Feb 20 '10 at 13:14
  • Except that the link isn't for the NDK AFAICT. It's for writing console apps, using the cross-compiler that's part of the Android open source project. The term "NDK" doesn't even appear on the page, and the post was written before the NDK was released. – CommonsWare Feb 20 '10 at 13:30
  • @CommonsWare: Ok, my mistake to call it "hello world with NDK", it was meant more as an example of something written in C. – Fredrik Feb 20 '10 at 13:51
  • @Conspicuous Compiler: Ok, I see the point. My intention was to help him with a keyword to start searching with, not only to find the NDK docs but to find tutorials and things others have written as well. I had the impression the OP didn't know about NDK as a term. I hope no-one considered it a lmgtfy-answer. – Fredrik Feb 20 '10 at 13:54
  • Heh, now that you've changed the link, my first comment seems nonsensical. Progress! – Conspicuous Compiler Feb 20 '10 at 20:49
  • @Conspicuous Compiler: Sorry, it was because of @CommonsWare's input, that link seemed to make more sense. As I said it is not (yet) my cup of tea, I just wanted to contribute with what I have picked up so far. – Fredrik Feb 20 '10 at 21:18
  • @Fredrik Hehe, no worries. It's probably a better link for this purpose. I'm just being silly. Cheers! – Conspicuous Compiler Feb 21 '10 at 11:49
  • i'm actually aware about the NDK and is asking if it's possible to create a full-screen OpenGL app that uses java wrapper to receive input (and possibly timer) events and output the buffer to the screen. The native lib should have persistent state, so the java wrapper will only run a main loop and call 'cycle' method inside the NDK lib. The second question was: can I put the pixels array directly on the screen without using OpenGL? – Hedin Feb 21 '10 at 16:58
2

With Gingerbread (Android 2.3) it looks like you can build your entire app in C++.

cf: http://phandroid.com/2011/01/11/android-developers-blog-awesome-ndk-leads-to-awesome-apps/

" With the latest version of the NDK, r5, many big improvements have been made to coincide with the release of Gingerbread. The most major is the ability to code a native application for Android 2.3 entirely in C++. This means even programmers and developers with no Java knowledge won’t have to implement a single line of that code..."

Can't vouch for the veracity of this blogger, however, from what I have read, it appears you can do this

user584566
  • 21
  • 1
1

There is no 100% native solution but what I think you are looking for is the Android NDK (Native Development Kit)

From their site "Please note that the NDK does not enable you to develop native-only applications. Android's primary runtime remains the Dalvik virtual machine."

I believe it lets you make calls to your own native code from an Android application

I have personally never used it for my games, but I am sure it would help on a lot of things (like being able to manage my own memory and not have "lag" do to the garbage collector)

snctln
  • 12,175
  • 6
  • 45
  • 42
1

conversations in this thread can help you. http://groups.google.com/group/android-ndk/browse_thread/thread/50362904ae0574cf

essence is, It is possible to make Native only apps and Android Market doesn't restrict you either. But with limited support for native development, there is high chance of using some of the non standard functionality which might break in future releases.

FL4SOF
  • 4,161
  • 6
  • 28
  • 24
0

http://developer.android.com/guide/basics/what-is-android.html

"The Android SDK provides the tools and APIs necessary to begin developing applications on the Android platform using the Java programming language."

http://arstechnica.com/open-source/news/2009/06/android-goes-beyond-java-gains-native-cc-dev-kit.ars

In general, you don't. There is some limited C++ support through JNI, but it is mostly intended to supplement Java code, not replace it. There's no framework/API support (AFAIK) for C++, so doing this isn't really an option.

James
  • 8,512
  • 1
  • 26
  • 28
  • I believe that OpenGL APIs at least are exposed directly on NDK level, so e.g. for full-screen games full native is definitely an option (and probably recommended). – Pavel Minaev Feb 20 '10 at 06:29