Installing and using Android NDK in Eclipse

I launched the Android SDK for a while in Eclipse (MAC OSX). I downloaded NDK and installed C / C ++ tools in Eclipse, but can anyone direct me to use NDK? For example, I just create an Android project, as usual, and instead create it using the NDK?

In fact, this can be done with a decent textbook if anyone knows about it.

EDIT: OK, so I have NDK installed (I think), but does anyone know how to use it? I got to this (taken from here ):

Launch terminal

cd ~ / android-ndk-1.5_r1

do APP = hello-jni

To run the hello-jni sample application, but I get an error in the terminal:

Android NDK: APP variable defined for unknown applications: hellojni
Android NDK: you can use one of the following:
build / core / main.mk: 81: *** Android NDK: Cancel. Stop.

Any ideas why?

+44
android installation android-ndk
Aug 12 2018-10-12
source share
5 answers

How can I describe this, creating an Android application from Eclipse using the NDK requires two steps.

Firstly, inside your terminal you need to run the NDK build script in your project. cd to the root directory of your project, and then run the ndk-build script inside this directory.

For example:

cd ~/workspace/hello-jni ./~/android-ndk-1.5_r1/ndk-build 

After that, you should see some output, the result of which is to create a * .SO file in the obj directory in the project directory.

Once you have the * .SO file, the last step to creating an Android NDK application through Eclipse is to create it using Eclipse, like any other application, and then deploy it for testing.

If you make any changes to the C / C ++ code, you will need to repeat the first step and restore the * .SO file before creating and deploying your application from Eclipse again.

I would like to note that with the Android NDK, your Android apps are still Java based. They simply communicate with code written in C / C ++ using the Java Native Interface .

Finally, I do not know any Eclipse plugins that will help in the development of the NDK. Everything I know about NDK, I found out the official Android NDK documentation . Please feel free to comment and let me know if there is anything that I can clarify in my answer.

+25
Apr 14 2018-12-21T00:
source share

Native development and debugging support appeared in the Eclipse environment according to ADT version 20. http://tools.android.com/recent/usingthendkplugin

  • Set NDK path from Eclipse Preferences -> Android -> NDK
  • Right-click your project and select "Android Tools" β†’ "Add Basic Support"

developer.android.com claims that you also need Cygwin.

http://developer.android.com/tools/sdk/ndk/index.html#Contents

Essential Development Tools

  • All development platforms require GNU Make 3.81 or later. Earlier versions of GNU Make may work, but have not been tested.
  • The latest awk version (either GNU Awk or Nawk) is also required.
  • Windows requires Cygwin 1.7 or higher. NDK will not work with Cygwin 1.5 installations.
+12
Sep 21 '13 at 9:07 on
source share

The docs directory in the NDK has pretty good information on how to use the NDK itself. Read the review of documents, applications .mk and Android.mk. You will want to make Google for Sun JNI PDF, download it and find out what JNI is before you go any further. This is because simply compiling a bunch of C / C ++ code into libraries with NDK is only part of the process. You must write your own Java code that calls your C / C ++, and you must create wrapper functions in C / C ++ that adhere to the JNI conventions that your own Java code can call. JNI has been around for a long time, not Android. So, you can find out quite a bit about this by following JNI-oriented tutorials using command line tools like javah and javac, and then return to integrating with NDK after you know the basics. (An example of how these C gaskets look like, look at the NDK hello-jni sample, the C source file shows how the gaskets usually look. Using javah to create these gaskets is the way you create Java classes that have their own methods, process them using javah and generate C headers for you, then you encode C functions that adhere to the created function prototypes).

Note: while in NDK documents you would manually create from the command line and then go to Eclipse to create your application (this would be a laborious sequence of steps, especially if you change the C / C ++ code), it turns out that You can easily integrate with Eclipse so that the NDK starts every time you build with Eclipse. To find out how, read here .

+5
Apr 15 2018-12-12T00:
source share

This is useful for others who want to create a project from scratch from within eclipse: I followed the steps mentioned here in this blog and it works great: http://mhandroid.wordpress.com/2011/01/23/using-eclipse- for-android-cc-development /

+2
May 23 '12 at 4:13
source share

To try to answer the question directly - you need to run ndk-build in a folder with its own code in the project folder. This creates .so files found in the file explorer / resource tree under jni in Eclipse. These functions, if the syntax in the code is correct, can now be called from your java code.

I found many sources of help installing and accessing the Android developer tools and NDK. I wrote a message to share my experience and hopefully bring back a community that helped me get there, which may help to understand my answer: http://workingmatt.blogspot.co.uk/2013/03/set-up-android- sdk-and-ndk.html

+1
Mar 31 '13 at 18:31
source share



All Articles