Use R7 NDK to build an Android Development Environment

Source: Internet
Author: User
Tags android sdk manager

Not much nonsense, just a few words.

This was originally written because of the company's project requirements. The leaders asked me to build an Android Development Environment (Eclipse + NDK). I calculated the information, downloaded, installed, configure the environment and write the document. It just takes one workday to complete. After editing the prepared documents, I will post them here. I think this will help some people, but I haven't written a blog for a long time, so my hands are itchy!

Now, start!

 

----------------- Split line ---------------

Installation Process

1. Install JDK.

2. Install eclipse(eclipse-cpp-indigo-sr1-incubation-win32.zip and decompress it. Note: This version integrates CDT)

3. Build an Android Development Environment (reference: http://developer.android.com/sdk/installing.html)

3.1 install Android SDK (installer_r16-windows)

3.2 install the ADT plug-in of Eclipse.

3.2.1 start Eclipse and select Help> Install New Software from the menu

3.2.2 click Add, enter a name, and then enter:

Http://dl-ssl.google.com/android/eclipse/, OK!

3.2.3 select the tool to be updated, Finish, and restart Eclipse after installation.

3.3 configure the ADT plug-in

3.3.1 start Eclipse and select Window> Preferences from the menu

3.3.2 select Android and select the SDK installation directory in SDK Location. OK!

Then restart Eclipse.

3.4 add platform and other components

3.4.1 start Eclipse and choose Window> Android SDK Manager from the menu.

3.4.2 select the corresponding component as needed, and then click install.

The following components can be installed by default, as shown in Figure 1:

 

(Figure 1)

3.4.3 create an Android virtual device. Select Window> AVD Manager in the menu.

New: create a virtual device. Set the parameters. 2:

4. Install NDK (R7, android-ndk-r7b-windows.zip, unzip to use)

Note: For versions earlier than R7, Cygwin must be installed to use NDK. From R7, Windows NDK provides a ndk-build.cmd script that can be compiled directly using it. To achieve this, you only need to add a Builder for the Eclipse Android project to implement Eclipse's automatic compilation of NDK.

 

(Figure 2)

5. Implementation of NDK instances

5.1 start Eclipse and create an Android Project (TestNDK), as shown in Figure 3:

 

(Figure 3)

5.2 create a folder jni under the root directory of the TestNDK project, and find Android under the NDK installation directory (\ samples \ hello-jni \ jni. mk and hello-jni.c, copy it to the TestNDK-> jni folder.

5.3 find hellojni under the NDK installation directory (\ samples \ hello-jni \ src \ com \ example \ HelloJni. copy the java file to the package corresponding to the src folder of the TestNDK project.

5.4 modify the project file AndroidManifest. xml, and change android: name = ". TestNDKActivity" under the activity tag to android: name = ". HelloJni ". (Note:

TestNDKACtivity is automatically generated for the project. Different projects are generated here)

5.5 create and configure a Builder

5.5.1 click Project-> Properties-> Builders-> New to create a New Builder. In the displayed dialog box, click Program, OK! 4:

 

(Figure 4)

5.5.2 in the pop-up dialog box "Edit Configuration", the Configuration tab "Main ]:

Location needs to fill in the path of the nkd-build.cmd (under the NDK installation directory ).

In Working Diretcoty, enter the project root directory of TestNDK.

5:

5.5.3 in the pop-up dialog box Edit Configuration, the Configuration tab Refresh ]:

Check "Refresh resources upon completion ",

Select The "The entire workspace ",

Select Recuresively include sub-folders ".

 

(Figure 5)

5.5.4 in the pop-up dialog box Edit Configuration, the Configuration tab Build Options ]:

Select "After a" Clean "",

Check "During manual builds ",

Check "During auto builds ",

Select Specify working set of relevant resources ".

Click "Specify Resources ..." Check the "jni" directory of the TestNDK project and Finish!

Save settings, OK!

5.5.5 right-click the Project TestNDK and Build the Project. When the information shown in section 6 is displayed on the console, everything is normal and the code is automatically compiled.

 

(Figure 6)

5.5.6 right-click the project TestNDK, Run As-> Android Application, and Run the program. When output

As shown in figure 7, the NDK instance runs successfully!

 

(Figure 7)

6. Possible Problems

8:

 

(Figure 8)

In the c file, the function name is defined as follows:

Java_testNDK_android_HelloJni_stringFromJNI is defined as JNI standard in the following format:

Java_packagename_classname_methodname,

Example: Java_testNDK_android_HelloJni_stringFromJNI

 

----------------- Split line -----------------

 

Due to my limited level, there will certainly be something wrong with the writing. You are welcome to point out the Q & A. I am here to give you some advice. Thank you ~

 

Welcome to reprint, reprint please indicate from: http://www.cnblogs.com/xiaomiao

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.