Cocos2d-x cainiao intern study win32 program porting to Android

Source: Internet
Author: User
Tags php download

1. First, you must know what you want to download !!! 1. eclipse download 32-bit (Official Website) Eclipse c ++ Version Download file =/technology/epp/downloads/release/indigo/SR2/eclipse-cpp-indigo-SR2-incubation-win32.zip 3. android SDK directly uses 32-bit (32-bit or 64-bit) and does not need to be installed. After downloading the SDK, decompress it to the appropriate directory. android SDK uses the Java language, therefore, JDK 5.0 and later must be installed first. It is more convenient to directly download and install the jdk Installation File. The Sdk contains eclipse, and the encoding tool version is too low. You can go to Baidu to download more than 20.) 4. android NDK uses 32-bit directly (32 or 64 is not distinguished). With this feature, Android can support c/c ++ 5. cygWin, I am too lazy to download and install it on the official website. I used a Baidu file (Cygwin Easy 2007.03.21 (ISO). After decompression, cut the cygwin directory directly to the C root directory. you can ignore me and install Baidu on CygWin. This download method will take a long time. But it is reliable (don't worry about it first, I will teach you how to install it later) II. Install eclipse and Its settings: You don't need to install it after download, and you can use it directly after decompression. Open eclipse. 1. If eclipse does not support Android, download the android component. Click help,-soft update (like this), and then fill in the Work with Column https://dl-ssl.google.com/android/eclipse/ After the eclipse search is complete, the ADT plug-in download project will be listed in the main window, select all, and click Next. If you have already downloaded the ADK, you can select "ADD", select "Archive" in the pop-up window, and enter your ADT storage path. Click Next again and the software license window appears. You need to check and agree, and then click Finish to download and install the ADT plug-in. Then restart eclipse, you can find the Android Project under the File-> New-> Project menu to prove that the ADT is successfully updated. 2. If eclipse does not support c ++ (my version is c ++ by default ), you need to download the CDT plug-in: CDT can be http://www.eclipse.org/cdt/downloads.php Download to. The corresponding CDT plug-in version of eclipse3.7.1 is CDT8.0.1. After the download is complete, start eclipse, select Help-> softwareupdates, click add to select archive, select the downloaded cdtplug ZIP file (cdt-master-8.0.1.zip), OK, check all installation items, and click next to start eclipse installation. Similarly, a software agreement option is selected during the installation process. After completion, eclipse will require the software to be restarted. OK. Restart eclipse and choose New> Projec. You will find that eclipse supports C/C ++ projects. 3. The purpose of associating NDK with NDK is to generate the *. so file that can run on arm for the code written in C/C ++. It is called by the java code of android. AndroidNDK can be http://developer.android.com/sdk/ndk/index.html Download the SDK. As of January 19, the latest version is r7 menu-window-preference-android-ndk. Enter the root directory of the ndk. 4. Download the android sdkAndroid SDK from http://developer.android.com/sdk/index.html Download to. As of January 19, the latest version is r16. Select the number of windows operating systems to download. After downloading, decompress the package to any path. After unzipping, the path does not contain any sdks. You also need to run SDK Manager.exe (under the downloaded SDK directory) to download the sdk package. The author did not download the latest SDK and updated it through r10 SDKManager. Update the r10 version of SDK Manager.exe to r15 to see the newly released SDK package. 5. cygwin installs Cygwin as a Linux Simulation Environment. Because the local *. so local library generated by NDK requires a cross-compilation environment, cross-compilation can only be completed in linux. Cygwin can http://cygwin.com/install.html Download. (You can choose to download but do not install the option to create a "Local installation package") during installation, the default installation configuration in Cygwin does not install the gcc compiler. We must use four component packages in the Devel class, if it is too difficult to find out, you can change the Devel class from Default to Install. Installation Process: Download a setup.exe file from the official network and run it. Step 1: run the setup program. The first step is shown in the figure below. Click Next to go to the Next step. Step 2: select the installation method. You can use DirectConnection to download and Install the package online for the first time. If you have a ready-made offline package, you can select Install from Local Directory ). Step 3: select the installation directory, such as C: \ Cygwin. Note that this directory refers to the final installation directory of Cygwin, rather than the temporary directory for downloading files. Step 4: Set the temporary directory for saving local packages to the same directory as setup.exe. The downloaded directory is in the format of ftp % 3a % 2f % 2fcygwin.mirrors.pair.com % 2f. Step 5: Set the network connection method Step 6: select the download site address and try to see which address is used when the speed is fast (if you do not feel fast, click Cancel and try again ). Step 7: Wait for the loaded installation items to load. Select the installation items and compile the NDK. Under the Default settings, you only need to select Devel (Click Devel in the list and change the following Default to Install, as shown by the arrow in the figure. Step 8: waiting for the download to be completed depends on the number of installation packages you select and the network connection speed. For example, it may take 4-5 hours to follow the default method in this article, after the package is downloaded, the package size is about 750 mb. After the package is downloaded, it is automatically installed in the installation directory set above. Reminder: after the first download is complete, you 'd better back up the downloaded package directory. You can directly use the offline Installation Method for the next installation of the same environment (select local installation in step 2 ). Run Cygwin once (Cygwin. bat) to create some user environment files, enter make-v and gcc-v respectively. if the check succeeds, make and gcc versions are printed, as shown in. (I have tried to download a 2G cygwin file. You can use it directly after decompression... Both Gcc-v and make-v have version information output .) 3. Create android Project 1: Create android project to go to the Engine Directory to find the create-android-project.bat file double-click to execute the General will prompt NO cygwin, android-sdk, NDK (Association is associated here, this path), so you must first install these things. Use UE to open the create-android-project.bat, and then modify the installation path of cygwin, NDK and so on. 1. Enter the android package name. I entered com. bearsoft. game. demo1. enter the android package name. I entered com. bearsoft. game. demo2. enter the project name. I entered win32androidDemo3. Enter the android version id. I entered version 3, that is, android2.1. (Note: here we enter the serial number according to the prompt. For example, this indicates that you only have version 4.2 available. If you want to use other android versions, you need to download them: there is an sdk manage under the E: \ android sdk \ adt-bundle-windows-x86 directory, click and select the version you want, and then download, the process may be a little persistent. 4. Now the android project has been created successfully. If an error is reported, see the following section. Skip this part if no error is reported. The error I encountered is: It doesn't matter. This is why CygWin is not configured, add the bin directory Path of CygWin to the path of the environment variable (my computer-right-click-properties-advanced-Environment Variable-Path modify:; E: \ cygwin \ bin 5. After the project is generated, enter proj. android/jni, edit android. mk: copy the prepared code file to the Classes directory under the project; copy the Resource file to the Resource Directory under the project. Open the Classes directory and find Android. mk. Use the editing tool to open it. Enter LOCAL_SRC_FILES: = in the cpp file to be compiled, save the file, and close it. For example: LOCAL_SRC_FILES: = AppDelegate. cpp \ GameOverScene. cpp \ Joystick. cpp \ TerribleGameScene. cpp 4. There are two methods to compile and compile, one is cygwin and the other is eclipse. First, open cygwin: 1. Enter the complete path of the Android folder in the project path, for example, cdd:/makeapk/MyGame/Android. Run the build_native.sh file. The specific input is./build_native.sh. 2. During compilation, the NDK_ROOT not define message may be displayed. This indicates that you have NOT created an NDK_ROOT environment variable in the environment variable. My computer-right-click Properties-advanced-environment variables, add these three environment variables: The content inside is: cocos2d-x installation root directory: E: /hzk/cocos2d-x/cocos2d-2.0-x-2.0.4, and NDK_MODULE_PATH: E:/hzk/cocos2d-x/cocos2d-2.0-x-2.0.4; E:/hzk/cocos2d-x/cocos2d-2.0-x-2.0.4/cocos2dx/platform/third_party/android/prebuilt also has NDK_ROOT: e: \ android \ android-ndk-r8 3. additionally, it is very troublesome to open cygwin and enter the complete path each time. You can use the following method to automatically execute some commands: use NotePad to open the cygwin root directory. \ etc \ bash. bashrc file. Add the command to the end of the file, for example, cd e: cdAPKMAKE/ko/android./ After build_native.sh is saved, these lines will be automatically executed when cygwin is run next time. 4. The compilation is complete. 5. Open eclipse and choose New> AndroidProfect to create a New android project. 6. Select an existing code to create a project and browse the android folder under the project directory. eclipse will automatically enter the project name and Finish. 7. Right-click the java file corresponding to the input project name to create a project, and choose Run As> RunConfigurations to enter the running settings. In the displayed dialog box, double-click the AndroidApplication option and select the project on the Android tab. Click the Run button. Because the *. apk file available on the real machine is generated in the <project path>/Android/bin path. Apk: Next, compile with eclipse: 1. Import the project. Remember not to select the copy option during the import. 2. Select the project after the import is successful, right-click androidtools-add native support -- 3. run as-run configuration -- select a simulator. It takes a long time to start compilation. The process is similar to cygwin. Check whether the dynamic library has been compiled. Go to the project directory and check whether the library is in libs. the reason for the so File black screen is: www.2cto. com1, did not manually copy the resource file to the ASSETS folder; 2, COCOS2D-X2.0 or above because the OPGELES relationship does not support simulators, so please use the real machine debugging; or may be 2.0.4 some problems, try PS for 2.0.3: The Simple Method for debugging on a real machine is to install a pea pod, because it is difficult to find a dedicated mobile phone driver, and the pea pod will help you install all the drivers, and then connect them directly. After the HELLOWORLD official sample program can run according to the above method, please refer to the official sample program. MK file, and then you can use your CLASS, resource, and MK file to transplant and compile your program. A slightly simpler method is to copy the MK file of the sample program into the CLASS and resource, and then try to run it. You can modify the icon and program name after running the program.

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.