Several scripts used for Android cocos2dx Development

Source: Internet
Author: User

1. X. SH is the script for dropping the current process X, because there are inevitably a lot of processes for restarting the application during debugging. Writing this part into the script saves you the need to go back every time. Of course, mainly used for the following two scripts

X. Sh is simply to use ADB devices to check how many devices are connected, and then each device PS | grep, and then kill-9. For some machines (for example, the zombie machine of Moto, although root but ADB Shell goes into the Shell Group by default, permission issues may occur. This process is complicated, so do not pull it)

#!/bin/shtarget_ps="com.kevin.test"tmpname="tmp"tmpfile=${PWD}/tmpnameawk 'BEGIN{  while("adb devices" |getline info)  {    split(info,devinfo);    if( devinfo[1] != "List" && devinfo[1] != "" )    {      print devinfo[1];    }  }}'>${tmpfile}cat ${tmpfile} | while read devnamedo echo "Kill device: " $devname " process" adb -s $devname shell kill -9 `adb -s $devname shell ps|grep ${target_ps} |awk '{ print $2 }'`donerm ${tmpfile}#kill iphone simulator instance#killall webgame
 
echo "Killed ${target_ps} process."

2. _ install. Sh

For cocos2dx for Android, it provides build_native.sh to call ndk compilation. But it is not convenient for us, because we have to switch to eclipse after compilation, refresh it, re-package it, upload it, and install it. SO _ intall. Sh is one step in place. The basic process is: Call X. Sh X to drop the previous process, call build_native.sh for compilation, call ant for packaging, and start with am start.

#!/bin/shapp_name=HelloWordpkg=com.kevin.testapp_root=${PWD}$app_root/x.sh$app_root/build_native.sh/usr/bin/ant -file $app_root/build.xml debug installif [ -n "$android_platform_tool" ]; then  android_platform_tool=$android_platform_tool/fi${android_platform_tool}adb shell am start -n $pkg/$pkg.$app_name

Note: _ install. Sh must be placed in the project root directory, because ant needs to read build. xml

In addition, PKG is the package name, app_name is the name of the activity to be started

3. Install. Sh

There is no lower bars at the beginning. Why install. sh? Because we found that every compilation, packaging, uploading, and installation is too time-consuming, and the project is large. This process is not completed in a few minutes, which is very inefficient. In addition, due to incremental compilation, we found that the time is not spent on compilation, mainly packaging, uploading, and installation of such operations involving SD card read/write is slow.

Cocos2dx is a C ++ cocos2d engine. for Android, dynamic libraries such as libgame. So will be generated for virtual machines to call. That is to say, if the change occurs in the C ++ code, we only need to replace the dynamic library and do not need to re-package and upload the entire project. We can see that after APK is installed, the library will be copied to/data/package name/libs. Therefore, install. Sh replaces the dynamic library after compilation and restarts without calling ant, which is similar to _ install. sh:

#!/bin/shapp_name=HelloWorldpkg=com.kevin.testapp_root=${PWD}$app_root/x.sh$app_root/build_native.shadb push $app_root/libs/armeabi/libgame.so /data/data/$pkg/lib/libgame.soecho "adb push $app_root/libs/armeabi/libgame.so /data/data/$pkg/lib/libgame.so"if [ -n "$android_platform_tool" ]; then  android_platform_tool=$android_platform_tool/fi${android_platform_tool}adb shell am start -n $pkg/$pkg.$app_name

It takes less than 10 seconds to update the code after modification.

Note: It must be configured in environment variables.

android_platform_tool

Is the tool folder of Android (that is, the location of ADB)

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.