building native components and packaging them with Java applications. Now we can see a line of text on our mobile phone.
V. Introduction to the project structure and main directories
1. jni Directory: contains the source code of the native component and the Make file (Android. mk) that describes the native component build method. This directory serves as the build directory for the NDK build project.
2.
) in ddms before executing debug in eclipse.During eclipse debugging, you can set breakpoints and perform one-step debugging. It is estimated that the Google team developed and debugged Android applications in this way.
7. Compile the android source codeRun:CD Android source code directory. Build/envsetup. ShThen there will be more commands such as mm/mmm. mm/Mmm
Kernel support for it and modify Android Source Code accordingly.7. Provide a firmware if your module needs it.8. Make your driver work with Android custom wpa_supplicant commands and siocsiwpriv IOCTL
Now onto details.0. Understand how Android wifi works.
Android uses a modifiedWpa_supplicant(External/wpa_supplicant)
Directory is generated. In addition, there is a generic_with_google.mk in the/build/target/product directory:
# This is a generic product That isn' t specialized for a specific device.# It includes des the base Android platform including some Google-specific features.# If you do not want to include Google specific features, you showould derive# From generic. mk
Using this
you click Finish, observe the Android project and generate three more folders, as shown in:
4. Compiling Andriod NDK code
Android NDK can be developed in C or C ++, but when C or C ++ is used to develop NDK, the functions provided by the C or C ++ standard library should be used.
5. In the Android. mk file and
Android Android-use Eclipse to develop the first android Application, android-android
Open Eclipse and select File-New-Android Application Project
Application Name is our Application Name, which is also the Name we see in the mob
\ intermediates \ classes \ debug) to classpath. In actual development, if you cannot find the class, add classpath on your own. Note that the classpath is separated by semicolons. In addition, if you think it is too troublesome to knock so many commands each time, you can also configure the classpath above to the system's environment variables. As for how to get it, I believe everyone is OK! This is not detailed here.
4. Implement the native METHOD
Create a hello. c file in the jni directory t
Dear friends, you may encounter problems such as the title.
I wrote an android project using Eclipse, but this project requires a hidden class of the SDK. All the classes that I want to compile under the source code will encounter errors after each mm, the prompt is that the corresponding class cannot be found.
The four jar packages that I need to add are as follows:
Org. apache. commons. codec-1.7.0.jar
Org. knopflerfish. bundle. kxml-LIB-2.3.0.jar
O
(the module name can be found in the. mk file ). After the module is compiled, the corresponding .apk package is generated under out/target/product/generic/system/app. However, the. APK compiled with mm/mmmwill not be packaged into the system. in IMG, We need to manually package the system folder as system through make Snod. IMG, but you have to re-run the simulator, which is also very troublesome. For our developers, we can do this:1. Remove the mod
the android directory, we can see the newly added compilation items:
4.2 run lunch full-Eng
Of course, we can also directly execute the lunch command and select our compilation items in the pop-up menu, as shown in:
Note: The compilation item we added already exists, but if you select it, an error will occur during compilation because we do not have a configuration file for the compilation item.
The lunch command can export important environment v
restart the device. The update takes effect.$./ADB Shell# Stop# Start
========================================================== ==========================================================
Makefile content in the android source directory:
### Do not edit this file ###Include build/CORE/Main. mk### Do not edit this file ###
Build/CORE/Main. mk contains build/CORE/
generated, We can compile the corresponding function code. Next, create the jni directory under the android project directory, that is ~ /Project/Android/JNITest/jni, copy the org_tonny_jni_JNITest.h header file to the jni directory, and create the org_tonny_jni_JNITest.c file under the jni directory. Edit the Code as follows:
# Include
# Include
# Include "org_tonny_jni_JNITest.h"
JNIEXPORT jstrin
connected, note that you must select a process (corresponding to an application) in ddms before executing debug in eclipse.During eclipse debugging, you can set breakpoints and perform one-step debugging. It is estimated that the Google team developed and debugged Android applications in this way.
7. Compile the android source codeRun:CDAndroid source code directory. Build/envsetup. ShThen there will be mo
.
Procedure
First, download the latest NDK compilation tool;
Then, compile the x86 library files in the NDK;
Finally, generate a new APK and test it;
Ndk compilation tool
Download windows or linux based on your operating system
The latest NDK compilation tool supports generating so libraries for both arm and x86 versions by setting them in your Application. mk
APP_ABI: = armeabi x86
Compile
Take the ubuntu operating system as an example.
, 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 provides a stable and functional API header file statement that supports very limited functions, including: C standard library (libc) and Standard Math Library (libm), compression library (libz), log Library (liblog ). 2) configure the environment windows: a).download
8800, "connection type" is standard (socket attach)Then "Apply"Note: The port set above must be the same as the port set in ddms. The ADT plug-in uses port 8700, so the port set above is 8800. If the VM cannot be connected, note that you must select a process (corresponding to an application) in ddms before executing debug in eclipse.During eclipse debugging, you can set breakpoints and perform one-step debugging. It is estimated that the Google team developed and debugged
environment configuration, there will be no such problem, and the rest of the problems will pop up!2. About "cocosbuilder/CocosBuilder. h" file not foundSimilar to the above situation, this requires modifying the proj. android/jni/Android. mk file. I am not very clear about the syntax of the Android.
.
To make it easier for everyone to understand the hook principle, we should first consider the arm instruction set, because arm is simpler than thumb and does not need to consider the instruction length. Therefore, we need to compile the so of target and hook into the arm instruction set form. How can this problem be solved? Simply add ". arm" after the file name in Android. mk (the actual file does not n
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.