今天看了這份資料 android模擬器adb指令

能夠從Ubuntu傳送apk到AVD裡來,還裝了angrybird

只是不能玩@@有點lag

但在這之前先來講一下adb這個指令,一開始其實是不能直接使用adb的

除非你知道他在哪,進到他的目錄內使用./執行也可以

但如果想要更方便使用adb,那就將tools、platformtools這兩個目錄加到環境變數來吧

sudo gedit ~/.bashrc

export PATH=$PATH:(sdk內tools的路徑)/tools

export PATH=$PATH:(sdk內tools的路徑)/tools:(sdk內tools的路徑)/platform-tools

加入環境變數後,android、adb等指令皆可以用了

下面是從參考資料參照來的指令

adb shell dir 就是列舉目錄

這行仍是我踏不過的坎

dir:not found

不理我就是不理我

安裝apk程序到模擬器:

adb install android123.apk   

 將想要放在模擬器下的apk放在android-sdk\Tools目錄下,就可以以這個指令裝到模擬器上。

這邊分享幾個我所出現的錯誤

apk已安裝上的錯誤.jpg 該app已經在運行錯誤.jpg 

左圖錯誤   右圖錯誤 

在我安裝button9.2.2.apk時出了這樣的錯誤,網路上的資料是說我已經裝上去了

但是= =第一次裝時就出現如右圖的錯誤

是我案太多次還是怎樣呢???

但是最後測試模擬上安上去的apk,有成功

向模擬器傳送文件:

adb push android123.txt /tmp/android123.txt   命令可以把SDK\Tools下的android123.txt文件傳輸到模擬器的/tmp/文件夾中

需要注意的是/tmp/文件夾中內容會在Android模擬器重新啟動時清空。除了說明了使用ADT插件中DDMS外

從模擬器中回傳文件到電腦:

adb pull /tmp/android123.txt android123.txt   命令就會把模擬器的tmp文件夾下android123.txt文件回傳到電腦SDK\Tools目錄下。

 端口號等信息,執行後會顯示TCP端口號

adb devices 

Android Debug Bridge version 1.0.26


 -d                            - directs command to the only connected USB device
                                 returns an error if more than one USB device is present.
 -e                            - directs command to the only running emulator.
                                 returns an error if more than one emulator is running.
 -s <serial number>            - directs command to the USB device or emulator with
                                 the given serial number. Overrides ANDROID_SERIAL
                                 environment variable.
 -p <product name or path>     - 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
 connect <host>[:<port>]       - connect to a device via TCP/IP
                                 Port 5555 is used by default if no port number is specified.
 disconnect [<host>[:<port>]]  - disconnect from a TCP/IP device.
                                 Port 5555 is used by default if no port number is specified.
                                 Using this ocmmand with no additional arguments
                                 will disconnect from all connected TCP/IP devices.


device commands:
  adb push <local> <remote>    - copy file/dir to device
  adb pull <remote> [<local>]  - copy file/dir from device
  adb sync [ <directory> ]     - copy host->device only if changed
                                 (-l means list but don't copy)
                                 (see 'adb help all')
  adb shell                    - run remote shell interactively
  adb shell <command>          - run remote shell command
  adb emu <command>            - run emulator console command
  adb logcat [ <filter-spec> ] - View device log
  adb forward <local> <remote> - forward socket connections
                                 forward specs are one of: 
                                   tcp:<port>
                                   localabstract:<unix domain socket name>
                                   localreserved:<unix domain socket name>
                                   localfilesystem:<unix domain socket name>
                                   dev:<character device name>
                                   jdwp:<process pid> (remote only)
  adb jdwp                     - list PIDs of processes hosting a JDWP transport
  adb install [-l] [-r] [-s] <file> - push this package file to the device and install it
                                 ('-l' means forward-lock the app)
                                 ('-r' means reinstall the app, keeping its data)
                                 ('-s' means install on SD card instead of internal storage)
  adb uninstall [-k] <package> - remove this app package from the device
                                 ('-k' means keep the data and cache directories)
  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


scripting:
  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-serialno             - prints: <serial-number>
  adb status-window            - continuously print device status for a specified device
  adb remount                  - remounts the /system partition on the device read-write
  adb reboot [bootloader|recovery] - reboots the device, optionally into the bootloader or recovery program
  adb reboot-bootloader        - reboots the device into the bootloader
  adb root                     - restarts the adbd daemon with root permissions
  adb usb                      - restarts the adbd daemon listening on USB
  adb tcpip <port>             - restarts the adbd daemon listening on TCP on the specified port
networking:
  adb ppp <tty> [parameters]   - Run PPP over USB.
 Note: you should not automatically start a PPP connection.
 <tty> 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 [ <directory> ]
  <localdir> can be interpreted in several ways:


  - If <directory> is not specified, both /system and /data partitions will be updated.


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


environmental variables:
  ADB_TRACE                    - Print debug information. A comma separated list of the following values
                                 1 or all, adb, sockets, packets, rwx, usb, sync, sysdeps, transport, jdwp
  ANDROID_SERIAL               - The serial number to connect to. -s takes priority over this if given.
  ANDROID_LOG_TAGS             - When used with the logcat option, only these debug tags are printed.

獲取設備型號

adb get-product

產生出來的資料有些看不懂


獲取序列號

adb get-serialno
 

emulator:5554

等待正在運行的設備


adb wait-for-device

端口轉發


adb forward adb forward tcp:5555 tcp:1234  實現將默認的TCP 5555端口轉發到1234端口上

查看bug報告


adb bugreport

上面那三個都不太懂,也沒出現什麼重要的資訊

 

大重點!!!!掛載虛擬的SD卡

 

產生SDCard的image file

mksdcard 1024M sdcard.iso   

讓SDCard連到Android Emulator

1../emulator -sdcard ~/.android/SDK-1.0/sdcard.iso

2.用Eclipse中設定程式的Open Run Dialog裏,Target頁籤的Aditional Emulator Command Line Option中加入啟動參數 -sdcard scard.iso

透過adb傳收檔案到emulator

應該是有兩種方法可以將SD連到模擬器上,但都失敗= =

Emulator]emulator: ERROR: the user data image is used by another emulator.
aborting

一直出這樣的錯誤 參考網站

第2種方法有網站可以參考

android創建SD卡

adb push 

adb pull

例如:adb push ~/mp3/audio.mp3 /sdcard/audio.mp3

這邊還沒做到

l進入emulator的shel

adb shell

arrow
arrow
    全站熱搜

    glitterHsin 發表在 痞客邦 留言(1) 人氣()