<span id="Label3"></p><p><p>In this chapter, the main introduction to the Android platform NDK configuration development has been at the end of the article attached to the understanding of this Sample. The full name of the NDK version used in this chapter is android-ndk64-r10-windows-x86_64.</p></p><p><p>After the download is complete, I unzipped the location under C:\AndroidNDK\.</p></p><p><p>Next open eclpise, in which you create a new Android project, named Testndk. After the creation is complete, create a new Jni file under its root directory.</p></p><p><p><br></p></p><p><p>Then open the Android-ndk-r10 file under androidndk, find the Android.mk and hello-jni.c two files inside, the path address is: app\android-ndk-r10\samples\hello-jni\ Jni</p></p><p><p>Copy two files to the Project's new JNI file, such as:</p></p><p><p><br></p></p><p><p>After completion, add the Hellojni.java file within the App\android-ndk-r10\samples\hello-jni\src\com\example\hellojni in the SRC directory of the Project. In the process of adding a notepad to open it first, find its package named com.examples.hellojni, in the SRC directory after creating a package with the same name, the Java file is copied into the Package.</p></p><p><p>finally, the name of the activity in the Project's maniefest file is com.example.hellojni.HelloJni, as shown below:</p></p><p><p><br></p></p><p><p>The C files and Java files that need to be added after the above are Complete.</p></p><p><p>Next we need to configure our project so that our project supports the NDK Compilation.</p></p><p><p>First click on project->properties->builders in eclipse, click New and select program, then click OK</p></p><p><p><br></p></p><p><p>And then, in the configuration dialog box that POPs up, make the following settings:</p></p><p><p>Fill in the location and working Directory in the Main tab</p></p><p><p>Location is filled in with the Ndk-build.cmd directory, working directory is filled in our engineering directory</p></p><p><p><br></p></p><p><p>Modify the refresh tag as Follows:</p></p><p><p><br></p></p><p><p>Modify the build tag as Follows:</p></p><p><p><br></p></p><p><p>Then click on the Specify Resource button in the Bulid tab, select our project in the inside, Tick.</p></p><p><p>Finally Determined.</p></p><p><p>At this point, the console column will show a message:</p></p><p><p><br></p></p><p><p>This allows us to complete the engineering Configuration. At this point, a real or virtual machine will run:</p></p><p><p><br></p></p><p><p><br></p></p><span style="color:#ff0000"><span style="color:#ff0000">analysis:</span></span>Here is just the small part of their own simple understanding, in-depth operation of the NDK after the introduction of the Principle. In this case, the main involved in the 2 files, one is Java Hellojni.java file, and the other is a hello-jni.c file, as for the android.mk file first do not say. In these two files we open a Java file to See:<br>You can see that this file is a activiy, so we previously replaced the name of the class file that started the activity in manifest, replaced by the mainactivity generated by the project by the Hellojni file, The acitivity information is recorded in the manifest configuration file, and each acitivity can be pointed to the target Java file by the Name property in the configuration bar <activity>. Next look at the parameter of the Tv.settext method is a function name stringfromjni, which we found here:<br>This is described for this function: this is a local method implemented by the local library "hello-jni", which must be wrapped in the Application. In fact, this local library is our c-language implementation of the library, which contains the C + + language Method. When the virtual machine is running, these libraries are called to the VM environment and the methods inside are Resolved. One of the main functions of the NDK is to facilitate the programming of the Java language and the programming interaction of the C + + language, invoking the underlying C + + library through Java. C at the bottom of the operating efficiency is relatively high. WE'LL Open it again. Hello-jni found there is only one method, the method is declared as Follows:<br>The name of the method is very long, but careful tube scraping can be found in fact this method consists of three parts: java+ (package Name) + (class Name) + (method name), so that the local method to implement the unique corresponding Declaration. In fact, it is in which package of which class which method called the local Method. So how to call the Java method to the local method, the previous said the loading library, so at the end of the Java file see the Following:<br>This is the static loading of the C language implementation of the library File. Detailed operating principle details will be described in another article.<p style="font-size:12px;"><p style="font-size:12px;">Copyright Notice: This article for Bo Master original article, without Bo Master permission not Reproduced.</p></p> <p><p>The ndk of Android's underlying base (i)</p></p></span>
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