Android's latest ndk R8 is built in the development environment of window

Source: Internet
Author: User
Android's latest ndk R8 is used to build, install, configure, and use a detailed graphic explanation in the development environment in the window. The complete configuration process record (original) has been trying to develop ndk, but it has been delaying other tasks, after referring to some online materials, I finally set up the environment and recorded the process and shared it with you. Content directory: 1. Default basic environment 2. Download and configure ndk 3. Install cygwin4. compile with ndk 5. Install CDT plug-in 6. Install Sequoyah plug-in 7. JNI compiling environment Configuration

Draw a mind map to show you the configuration process at a glance

 

------------------------------------------- 1. The default basic environment is to set up the android development environment. The following environments are available: jdk1.6.0 _ 07, eclipse3.6 (Helios), Android SDK, and ADT. You must first create an android virtual machine, run an android application, and then run ndk. 2. Download and configure Android ndk for Android ndk: cannot be opened sometimes, so be patient. Choose windowsandroid-ndk-r8c-windows.zip 233787657 bytes (104 MB) download and decompress it to your working directory, for example: e: \ Android \ android-ndk-r8. The samples folder contains 12 demo projects for instance development, is a good learning resource. 3. to install the compiling environment of cygwin C/C ++, Linux GCC is required. In Windows, cygwin is used to simulate Linux: http://cygwin.com/install.htmland click a connection of setup.exe to download it, this is only a downloaded boot program. The actual content is downloaded only after the next step. It takes a long time to download the package of 0.97gb. 1. Run the setup.exe program and click Next to go to the next step. 2. Select the installation method. For the first time, you can use direct connection to download and install the package online. If you have a ready-made offline package, you can select offline installation (install from local directory ). 3. Select the installation directory. For example, D: \ cygwin. Note that this directory is the installation directory of the cygwin virtual machine, not the temporary directory for downloading files or the ndk directory. 4. Set the path for saving local packages. The current directory is stored in the same directory of setup.exe. My files are HTTP % 3A % 2f % 2fmirrors.163.com % 2 fcygwin % 2f, which can be backed up.

 

 

Note: a warning box will pop up for the first installation. Click OK.

5. Set the network connection mode. Select the first one. 6. Select the download site address and select the first 163 site. The download speed can reach 185 KB. 7. After the installation item is loaded, click devel-default to change to devel-install. Do not change other settings. Next, download.

 

8. Wait for the download to complete. It may take about an hour. After the download is complete, click Next to install. The installation takes a long time.

 

9. run "cygwin. bat ", enter the" cygcheck-C cygwin "command to print the current cygwin version and running status. If the status is OK, cygwin runs normally. 10. Enter the "make-V" and "gcc-V" commands. If the check succeeds, make and GCC versions will be printed out. 11. Set the ndk path and add the ndk path to the Windows system environment variable. Using a Linux-style path like/cygdrive/e/Android/android-ndk-r8, cygwin issues a warning when compiling with E: \ Android \ android-ndk-r8 under windows. 12. run the cygwin command line. You can directly use the $ ndk environment variable. You do not need to manually enter the directory every time. 4. Compile the program using ndk: 1) Compile the sample program provided by ndk hello-JNI (E: \ Android \ android-ndk-r8 \ samples \ hello-JNI ). 1. Run cygwin and enter "CD $ ndk/samples/Hello-JNI/" to go to the "hello-JNI" project directory. 2. Enter "$ ndk/ndk-build" to compile. Ndk-build is the Compilation Program that calls ndk.

3. Run the LS command to check whether the so file is generated under libs/armeabi/. If there is a libhello-jni.so, The ndk runs normally. $ Ls libs/armeabi/GDB. Setup gdbserver libhello-jni.so can also go to the E: \ Android \ android-ndk-r8 \ samples \ hello-JNI \ libs \ armeabi directory to see if there is any generated. So file.

 

 

2) import the hello-JNI example of ndk to eclipse. 1. Create an android project hellojni in eclipse. Select "Create project from existing source" when creating Android project, and enter E: \ Android \ android-ndk-r8 \ samples \ hello-JNI in location.

 

 

2. Run the com. example. hellojni. hellojni project directly with Android aplication. The. So file must be available before it can run. 5. Import the static target Library to the android Project

After compilation is complete, you will get *. after the so static target library is used, it can be imported into the eclipse Android project of the engineering environment. Note that ndk programming does not necessarily require importing this target library into the android project, in addition to the usage described in this step, the android source code is also directly modified, compiled, and then burned into the development mode of the test machine, in this way, the default installation of the application, permission boot upgrade, and other "thorough" functions can be implemented. Overall:

This step demonstrates the ndk target library + andriod APK style. In addition, there are Android source code direct development and direct compilation methods (to be exact, the so-called Android engineering concept has been deprecated, of course, source code development does not seem to be available in windows at present. It seems that it must be carried out in the Linux family system, which will be covered in a later article)

The usage is as follows (example ):

1. Create a new project hellojni and hellojni in eclipse. for the code in Java, refer to the Demo code (android-ndk-r8b \ samples \ hello-JNI \ tests \ SRC \ com \ example \ hellojnitest) under the sample corresponding to ndk to call the method.

2. Copy the JNI and libs folders under the ndk compilation project directory to the new project directory.

Note that the two folders must be in the same directory as the SRC and res files in the project. Then go to eclipse to refresh the project (two more folders will be displayed ).

3. Run the Eclipse project, you can see the output string in the hello-jni.c function on the virtual machine.

4. Later, you can try to modify the Library source program or project Java program to familiarize yourself with the entire ndk development process.

6. Integrating the C/C ++ Development Environment cdtcdt plug-in eclipse allows you to develop both C/C ++-based native code and Java-based code in a project, with the Sequoyah plug-in, you can compile two pieces of code at a time. : Http://www.eclipse.org/cdt/downloads.php is different from the actual sever to download the corresponding package. If no package is installed, it cannot be installed. Help --> about eclipse can see their own version, my version: Helios Service Release 2 is Helios version http://www.eclipse.org/downloads/download.php? File =/tools/CDT/releases/Helios/Dist/cdt-master-7.0.2.zipcdt-master-7.0.2.zip: This is the offline installation package for CDT. (Because the file is large, we recommend that you use an offline package, 54.8 MB of 7.0.2, 103 MB of 8.1.1) install: eclipse-> help-> install new software, and click Add. Name: CDT _ version.

Location: Click archiveto locate the downloaded cdt-master-7.0.2.zip file.

If the "Duplicate location" error occurs below the location, go to window-> preferences-> install/update-> avaliable software site and find remove. If an eclipse package is missing, it means that the version you downloaded does not match the eclipse version. You can re-download and re-install it.

 

In addition, it takes effect only after you restart eclipse. After the installation is restarted, create a new project in eclispe. If the C/C ++ project appears, it indicates that the CDT plug-in is successfully installed.

 

6. Install the Sequoyah plug-in (you must install CDT before you can install this plug-in. You can directly install the latest version 2.0). The Sequoyah plug-in is used to set Android project support for native development. Official Website: Waiting for Helios Sr2 Sequoyah version: http://download.eclipse.org/sequoyah/updates/1.0.2/ Note: Just install 1.0.2 does not come out of the "local development" configuration so can not be used, I re-installed 2.0 can be, you can install the latest version 2.0 directly. On the installation page, do not check the "Group items by category" check box. If the list is empty (there are no categorized items. Add the ndk path in "window-> preferences-> Android-> Local Development.

 

After installing this plug-in, you also need to restart eclipse and then right-click the previously created "hellojni" project. The "android Tools" option contains "add native support ..." Option is successful.

 

VII. JNI compiling environment configuration now modify the "/hellojni/JNI/hello-jni.c" file, the dynamic link library libhello-jni.so file will not be recompiled to generate. You must add the compilation configuration and dependent libraries to the JNI project. 1. Conversion Project: Create a project and select "convert to a C/C ++ Project (adds C/C ++ nature)" under "C/C ++ )". Go to "Next ". 2. Select the "hellojni" project you just created, select "makefile project" on the left, select "cygwin GCC" on the right, and click Finish to create the project.

 

3. Right-click the "hellojni" project and select "properties ". Configure "C/C ++ build": click "C/C ++ build" and remove the "use default build command" check box selected by default in "Builder Settings" on the right.

Set build command to bash E: \ Android \ android-ndk-r8 \ ndk-build ".

 

4. Configure the dependency Library: C/C ++ general-> paths and symbols: add the new GNU and C dependency paths under the dependencies des. The "hellojni" project requires "E: \ Android \ android-ndk-r8 \ platforms \ Android-8 \ arch-Arm \ USR \ include", and then select different dependent libraries based on different projects.

 

5. Replace the string "hello from JNI!" in "/hellojni/JNI/hello-jni.c !", Change to "Hello JNI from zdz !"

 

6. After running, the output string on the simulator is "Hello JNI from zdz !" This indicates that the configuration is successful.

 

7. ndk R8 supports Android-8 and later versions.

Now you can develop C/C ++-based native code and Java-based code in a project at the same time, and there is no difference between developing ndk applications and developing common android applications.

 

You are welcome to comment on the discussion. If you have any questions, you can submit them in the comments. The comments will be updated and supplemented. Some cygwin installation procedures and precautions have been added.

Sort out an article about how to use ndk to transplant FFMPEG.

Http://www.cnblogs.com/zdz8207/archive/2012/11/27/android-ndk-install.html

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.