* to start emulator
./emulator -console
* to xfer a file to emulator; this is stored in emulator's userdata.img file
adb push <file> <dst file>
* to copy a file or a directory recursively to emulator
adb push <source> <destination>
* to copy a file or a directory recursively from emulator
adb pull <source> <destination>
* emulator can run native ARM Linux code.
build your apps using GNU/ARM Linux toolchain and then run in emulator.
* to get a shell on the emulator
adb shell
* to run a console app on Android emulator
adb shell <Linux command>
* to connect to emulator console for specific commands
telnet localhost 5554/6/8
Building and Running a native C++ App on the Android Emulator
References
Native C "Hello World" working in emulator
http://groups.google.com/group/android-dev...87cc
Native C Applications for Android
http://benno.id.au/blog/2007/11/13/android-native-apps
Steps
* download and install GNU/ARM Linux tool chain
http://www.codesourcery.com/gnu_toolcha ... nload.html
* create C/C++ code. see below for sample code.
* build app without dynamic libraries using GNU/ARM Linux toolchain
ex. arm-none-linux-gnueabi-g++.exe -static -o hello HelloAndroid.cpp
* start emulator in Windows by double clicking on $SDK_ROOT/tools/emulator.exe
* in a Windows Command window, use "adb" to xfer executable to emulator disk
adb push hello /system/sbin/hello
* make your app executable; do not use chmod ugo+x
adb shell chmod 777 /system/sbin/hello
* run your app in a console on the emulator
adb shell
cd /system/sbin/
hello
EXAMPLE HELLO WORLD C++ CODE
Using c Syntax Highlighting
- EXAMPLE HELLO WORLD C++ CODE
- //
- // HelloAndroid.cpp
- //
- //
- #include <iostream>
- 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;
- }
Parsed in 0.004 seconds, using GeSHi 1.0.8.4




