Learning Journey Based on Android NDK ----- Preface

Source: Internet
Author: User

A few days ago, I made an Android project. The engine layer uses C to write articles about this category, I would like to share with my friends my experience with NDK and my summary and notes on my knowledge. I hope to provide some help to those who need this information.
It mainly involves:
Environment Construction
Android. mk file configuration
HelloWorld
NDK print information
JNI Data Type
Java calls C and C calls Java:
Data transmission between Java --- C (Transmission of basic data types, transmission of String, transmission of objects, transmission of arrays, etc)
Create a Java object in C
Java method ing in C (including signature usage)
How to call Java methods in C (including static and non-static methods, as well as parameter transfer and return value processing)
Resources in JNI are released.
 
 
First, we will introduce NDK and JNI in detail:
 
What is the NDK?
 
Google Say:
The Android NDK is a toolset that lets you embed components that make use of native code in your Android applications.
Android applications run in the Dalvik virtual machine. the NDK allows you to implement parts of your applications using native-code versions ages such as C and C ++. this can provide benefits to certain classes of applications, in the form of reuse of existing code and in some cases increased speed.
 
[Android NDK is a collection of tools that allow you to embed components and use native code in your Android Application.
Android applications are executed on virtual machines. NDK allows your applications to be implemented through native code such as C and C ++. this will bring benefits to some applications. In this way, code can be reused and the execution speed can be improved in some cases. (For personal Translation, please note that the translation is inaccurate)
 
NDK stands for Native Development Kit.
 
Android NDK is a tool used with the Android SDK. Google's launch of NDK is not intended to replace the Android SDK, but cannot be completely replaced. It is just a supplement to the Android SDK. The native code used to compile the application.
1. NDK is a collection of tools.
* NDK provides a series of tools to help developers quickly develop C (or C ++) dynamic libraries and automatically package so and java applications into apk. These tools are of great help to developers.
* The NDK integrates the cross compiler and provides mk files to isolate differences such as CPU, platform, and ABI, developers can create so simply by modifying the mk file (indicating "which files need to be compiled" and "Compilation feature requirements.
* NDK can automatically package so and Java applications, greatly reducing developers' packaging work.
2. NDK provides a stable and functional API header file statement.
Google explicitly states that this API is stable and supports the currently released API in all subsequent versions. From the NDK version, we can see that these Apis support very limited functions, including: C standard library (libc), standard Math Library (libm), and compression library (libz), Log Library (liblog ).
 
What is the JNI?
Sun say:
THE Java Native Interface (JNI) is a powerful feature of the Java platform.
Applications that use the JNI can in1_ate native code written in programming versions such as C and C ++, as well as code written in the Java programming language. the JNI allows programmers to take advantage of the power of the Java platform, without having to abandon their investors in legacy code. because the JNI is a part of the Java platform, programmers can address interoperability issues once, and perform CT their solution to work with all implementations of the Java platform.
 
JNI is the abbreviation of Java Native Interface. Java Native Interface (JNI) standards have become part of the java platform since Java1.1. It allows Java code to interact with code written in other languages. JNI was initially designed for locally compiled languages, especially C and C ++, but it does not prevent you from using other languages, as long as the call conventions are supported.
 
 
There are too many introductions on the Internet. GA
 
 
Click to download frequently used documents:
NDK R5 Docs.rar
JNI Docs.rar
Try to write an article one day. Next I will explain how to build the elipse sdk ndk cygwin cdt environment.
 
 
This article is from the "Duicky" blog

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.