Give your own Android literacy text-1

Source: Internet
Author: User

1. You need to know that Android development is the beginning of the Java thing, no other language what things, that is, Google provides the Android SDK API is Java API
2. As for the strong cross-platform language, you know, non-C + + MO, said that Java is cross-platform, that is a rip, no Java virtual machine to see you can run Java not, and C + + language is the program directly compiled cost of machine code, which is completely different from the language of Java
So the problem is, I develop the game to use cross-platform language such as C + +, but Android is developed in Java, I write in C + + code can not be compiled under the Android, run. Keep C + + programmers out of the way, Google won't do such a stupid thing

Okay, the first question is, how do you compile and run C + + written code under Android?
The answer is: Use the NDK to compile C + + under Android

There's something I want to give myself a little bit of science.
On the Java platform, there is something called JNI, and its function is to allow Java code to interact with code written in other languages.
Before the NDK R5, you would want to develop under Android using C/D + +, only as a dynamic-link library, and then invoke these libraries in Java with JNI
After NDK R5, you'll be able to develop Android programs in pure C/s, which is the 2011 thing.
To the beginning of the 2015, there is a problem many people do not understand, why on Android is not to engage in a JVM, originally embedded development CPU and memory are very valuable resources, and in this aspect of the control C + + do better than Java
As for the reason, personally think, now hardware manufacturers are too many, you on the PC above the development program is generally run under the same operating system, and the operating system to shield the differences between these hardware, but Android does not at the system level of shielding the difference between the hardware, Instead of using the JVM to mask the differences between the hardware, it's no wonder it's a little bit slower to get a JVM system on top of the Android system.
However, the latest Android system has supported the direct use of C + + compile cost to run the language, and not run on the JVM, I think Android is still very dead end

Okay, now turn around and talk about the NDK, which says earlier on Android use the NDK to compile C + + code into libraries, which are then called by Java through JNI
What is the NDK, Google's official explanation is the SDK before adding native, then called NSDK, he thought, or the NDK is better, this is just a title
So what's the NDK? It's a set of Toolsets that allow you to implement part of your app in the C + + language

OK, let's create an Android project.
All the local code will be stored in a folder called JNI, open it to see it.
There is a android.mk file that is used to build the project
There is a application.mk file that is used to store compilation parameters (although it is not required)
Create a ndk-build file to show the compilation process (also not required)

Reference documents
Http://www.importnew.com/8038.html
Http://www.importnew.com/8052.html
Http://www.cnblogs.com/qq78292959/category/304331.html < This is the Android NDK translation series >

Give your own Android literacy text-1

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.