5

I am a new Android developer and I would like to create an application using only C/C++ code for Android but I have found the documentation to be very limited. I can create an Android C/C++ project in eclipse, but it uses a lot of java code.

I'm using NativeActivity (new to 2.3) and I need help setting up my project. Does anyone know how to do this?

http://developer.android.com/reference/android/app/NativeActivity.html

2
  • There are tutorials and docs for setting up a project. It needs to use Java to set up some native code, but that is as it should be. What is your exact problem? (i.e. Please ask a more specific question.) Commented Jan 31, 2011 at 18:43
  • I had the same problem. You can find the solution here. Commented Mar 4, 2011 at 8:57

2 Answers 2

3

Just remove all of the generated Java code. You don't need it if you want a purely native activity. The only thing you need to do is to set up the Android Manifest file as shown in the documentation. In particular, you'll need:

        <!-- Tell NativeActivity the name of or .so -->
        <meta-data android:name="android.app.lib_name"
                android:value="native-activity" />

And you'll need to modify jni/Android.mk so that it builds a jni with the name lib_name.

Sign up to request clarification or add additional context in comments.

3 Comments

You'll need to be using the latest NDK (r5) for this to work, by the way.
For for information on the native activity API, see: $(NDK_ROOT)/docs/NATIVE-ACTIVITY.HTML
I am looking at developer.android.com/sdk/ndk/overview.html .It also says "Compile the native code using the ndk-build command. " "cd <ndk-root>/samples/hello-jni" "<ndk_root>/ndk-build". However, when I try to do that I get "'C:\android\android-ndk-r5\ndk-build' is not recognized as an internal or external command". I am trying to run "C:\android\android-ndk-r5\samples\hello-jni>C:\android\android-ndk-r5\ndk-build"
0

Yuo can look into the Lighthouse project for android, which allows you to use Qt (and therefore C++) code instead of java. You still need 1 line of java code to kick off your Qt app.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.