Chinaunix首页 | 论坛 | 博客
  • 博客访问: 15530220
  • 博文数量: 2005
  • 博客积分: 11986
  • 博客等级: 上将
  • 技术积分: 22535
  • 用 户 组: 普通用户
  • 注册时间: 2007-05-17 13:56
文章分类

全部博文(2005)

文章存档

2014年(2)

2013年(2)

2012年(16)

2011年(66)

2010年(368)

2009年(743)

2008年(491)

2007年(317)

分类: LINUX

2008-08-01 11:24:54

adb push host文件 emulator目地路径

adb shell 登录emulator

adb logcat捕捉emulator的log

adb shell之后也可运行logcat

adb kill-server    将pc上的server干掉
adb start-server   将pc上的server重启,这样adb新的设置就ok了.
adb shell

adb和emulator等工具在Android的SDK的tool目录下:

android-sdk_m5-rc15_linux-x86/tools
|-- NOTICE
|-- aapt
|-- activityCreator.py
|-- adb
|-- aidl
|-- ddms
|-- dmtracedump
|-- dx
|-- emulator
|-- emulator_orig
|-- lib
|-- mksdcard
|-- sqlite3
`-- traceview

http://benno.id.au/blog/2007/11/13/android-native-apps


ANDROID 技巧

运行模拟器
emulator -console

* 将文件写入到模拟器的userdata.img文件中
adb push

*将一个目录拷贝到模拟器中,包括子目录
adb push

* 将一个目录从模拟器中拷出来
adb pull

* 使得模拟器可以运行arm代码.
使用GNU/ARM Linux编译器编译你的应用程序就可以了

* 在模拟器里面运行shell,需要先运行模拟器
adb shell

*运行模拟器中的一个控制台程序
adb shell

*连接模拟器的控制台
telnet localhost 5554/6/8

运行C程序

参考文献

Native C “Hello World” working in emulator
… wse_thread/threa…

Native C Applications for Android
http://benno.id.au/blog/2007/11/13/android-native-apps

步骤
* 下载GNU/ARM编译工具

* 编写c/c++代码.

* 使用GNU/ARM Linux 工具创建一个应用程序,不使用动态链接库
ex. arm-none-linux-gnueabi-g++.exe -static -o hello HelloAndroid.cpp

* 启动模拟器
$SDK_ROOT/tools/emulator.exe

* 在命令行窗口运行 abd将编译好的hello程序放入模拟器的磁盘
adb push hello /system/sbin/hello

* 让hello文件变成可执行程序,不要使用 chmod ugo+x
adb shell chmod 777 /system/sbin/hello

* 运行hello程序
adb shell
cd /system/sbin/
hello

EXAMPLE HELLO WORLD CODE
//
// HelloAndroid.cpp
//
//

#include
using std::cin;
using std::cout;
using std::endl;

class MyName
{
public:
void getname( void );
void sayhello( void );

private:
char name[ 255 ];

};

void MyName::getname( void )
{
cout << “What is your name? “;
cin >> name;

}

void MyName::sayhello( void )
{
cout << “Welcome ” << name << ” to the world of Android” << endl;

}

MyName name;

int main( int argc, char *argv[] )
{
name.getname();
name.sayhello();
return 0;
}

==============================================

Android Debug Bridge version 1.0.17

 -d             - directs command to a specific device
 -p      - simple product name like 'sooner', or
                                 a relative/absolute path to a product
                                 out directory like 'out/target/product/sooner'.
                                 If -p is not specified, the ANDROID_PRODUCT_OUT
                                 environment variable is used, which must
                                 be an absolute path.
 devices                       - list all connected devices

device commands:
  adb update DATAOPTS    - Flash the specified update file.
                                 If file is not passed, update.zip is used.
  adb push     - copy file/dir to device
  adb pull     - copy file/dir from device
  adb sync [ ]      - copy host->device only if changed
                                 (see 'adb help all')
  adb shell                    - run remote shell interactively
  adb shell           - run remote shell command
  adb logcat [ ] - View device log
  adb forward - forward socket connections
                                 forward specs are one of:
                                   tcp:
                                   local:
                                   dev:
  adb install             - push this app to the data partition
  adb bugreport                - return all information from the device
                                 that should be included in a bug report.

  adb help                     - show this help message
  adb version                  - show version num

DATAOPTS:
 (no option)                   - don't touch the data partition
  -w                           - wipe the data partition
  -d                           - flash the data partition

bootloader commands:
  adb flashall DATAOPTS        - reflash the device from the build output tree
  adb flash [] []  - write to flash
  adb send        - write to ram
  adb debug                    - listen to bootloader debuglog
  adb bl              - send raw bootloader command

scripting:
  adb wait-for-bootloader      - block until bootloader is online
  adb wait-for-device          - block until device is online
  adb start-server             - ensure that there is a server running
  adb kill-server              - kill the server if it is running
  adb get-state                - prints: offline | bootloader | device
  adb get-product              - prints:
  adb get-serialno             - prints:

networking:
  adb ppp [parameters]   - Run PPP over USB.
 Note: you should not automatically start a PDP connection.
  refers to the tty for PPP stream. Eg. dev:/dev/omap_csmi_tty1
 [parameters] - Eg. defaultroute debug dump local notty usepeerdns

adb sync notes: adb sync [ ]
  can be interpreted in several ways:

  - If it not specified, both /system and /data partitions will be updated.

  - If it is "system" or "data", only the corresponding partition
    is updated.

  - If it is a path to a local directory, the name is examined to see if
    it points to a directory named ".../system" or ".../data", or if
    the directory contains subdirectories with those names.  If so, it pushes
    the appropriate directory/ies to the device.

  - If the name of the local directory does not match ".../system" or
    ".../data", it is treated like an "system" directory.

  - If points to a nonexistent directory, adb sync will fail.

阅读(5904) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~