The following information only prepares for forgetting.
The following is a process record on how to configure and install the android environment.
1. First install JDK, which contains the Java Runtime Environment
2. Install eclipse, which is a tool used to write code, similar to vs or xcode,
3. after installing eclipse, download the ADT on the Internet. This is a control prepared for compiling the android program in eclipse. After downloading it, unpack it, then place it in the folder generated by ECLIPSE installation. (You can choose whether to replace the file ). You can also configure the ADT by entering the ADT installation address in eclipse --> help --> install new software.
4. Download the android SDK online. After downloading the SDK, unpack it. Start eclipse --> Windows --> preferences and select the android item on the left of preferences. Then, select the path of SDK location in the interface on the right.
5. after installing the android SDK, restart eclipse and create an AVD under eclipse> Windows> Android SDK and AVD manager. If it is started successfully, the android SDK has been installed.
Create a new andriod project and run it to see if it works properly. If it runs normally, the environment has been configured.
If it cannot be run yet, refer to the online information. Some may say that you still need to configure the PATH environment variable in the "my computer" attribute. For details, refer to the online information.
Next, let's talk about ndk,
Due to the wide variety of mobile phone configurations running on Android, running some programs on low-configuration mobile phones may fail because the configuration is too low. Because Android adopts Java programming and is a virtual machine mechanism, its running efficiency will be very influential. Generally, a better way is to screen or operate data at the network layer, in addition, when data is frequently exchanged, we recommend that you use the underlying C or C ++ to perform time-consuming operations. Therefore, this involves the mutual calls between Java and C.
Java cannot directly call the DLL written in C, or the EXE code or library file. You need to use the ndk for intermediate conversion. For more information about how to install the ndk, see another article I posted.
1. After the ndk is installed, copy the written. c file, create a new JNI folder, and put the. c file under this folder,
2. Start the cygwin program, run CD to the JNI folder, and enter the $ ndk/ndk-build command. After the command is run successfully, a libs folder is generated, and place the generated so file in it. Add the libs folder in the program, which is the same as JNI.
3. Call the function in. c In. Java code. For example, you can use _ textview. settext (stringfromjni. In this way, the. C code is called in Java.
But you can see this in eclipse. the C file is not recognized because the C/C ++ environment plug-in is not installed: CDT, which is mentioned in my article about how ndk, after the CDT is installed, open eclipse again. c files can be viewed and modified. However, if you want to re-compile the. c file after modification, you still need to use the ndk command to re-generate the. So file and then call it in the code.
Check the function name in the. c file, such as java_com_example_hellojni_hellojni_stringfromjni ();
Specifically, Java is required first, followed by the package name com. example. hellojni using this method, followed by the current project name hellojni, followed by the specific function name. Use stringfromjni () to call this method in Android.