2

I try to import example projects using Android NDK 7 into Eclipse. The problem is that no matter how I do it. The project always ends up being completely empty.

For example I tried to import the hello-jni example. I have both tried to import it via:

  • New -> Project -> Android Project -> Create project from existing source
  • Import -> Existing Projects into Workspace

Both times the computer seems to find the AndroidManifest.xml as it correctly fills out the fields for package name, etc. But as soon as I press Finish I only have an empty project. The same procedure works for Android Projects not using the NDK as e.g. the Snake example from Android SDK. The behaviour is also consistent between MacOSX Lion and Windows.

What do I need to import the existing Android NDK examples into Eclipse.

NOTE: I managed to import the projects, when I copy the ndk into the root directory. However in the NDK documentation it says I can put in into any directory I want and I would rather not have it in the root directory. Any ideas why it only works there?

gebirgsbärbel
  • 2,327
  • 1
  • 22
  • 38

2 Answers2

0

You can compile in eclipse though, In Short :-

This assumes you can compile from command line, i.e. you have ndk-build on your path so you can call ndk-build from command line.

This works on in Helios Version: Helios Service Release 2.

Download the CDT plugin for Eclipse for starters, i presume you know how to get plugins into Eclipse. its under LANGUAGES , install all non incubation plugins for C/C++.

Create your Android Java project (or import the example project), add your JNI folder and also your Android.mk in this directory.

Go FILE / NEW / OTHER

Then if CDT is installed correctly Under C/C++ / ( Convert to a C/C++ Project )

Check the project, choose MakeFile Project and Other Toolchain click NEXT

Next go PROJECT / PROPERTIES / C/C++ uncheck " use default build command" replace "make" with "ndk-build"

This works for me :)

Dev2rights
  • 3,469
  • 3
  • 25
  • 42
-1

Probably you don't have .so file. Use cygwin and ndk-build to create it. In jni folder you have .mk file

pascal
  • 59
  • 4
  • Yes I can do that, but I still want to be able to work with eclipse as it is by far more comfortable if I want to change things in the projects and the existing examples would be a good starting point. Is there any way to create the .so file. What is it for? – gebirgsbärbel Nov 30 '11 at 18:07
  • no you can't use eclipse to create .so file. But when you change something in c++ you only save changes, compile with ndk-build, refresh project in eclipse and ready. SO file is like .dll file on windows. It is dynamic library with your native functions – pascal Dec 01 '11 at 11:38