mac環境でのadbの使用

1628 ワード

ステップ1:adb環境の構成
maleideMacBook-Pro:~ malei$ cd $HOME  //     
maleideMacBook-Pro:~ malei$ touch .base_profile  //    
maleideMacBook-Pro:~ malei$ open -e .bash_profile  //    
-------------
      :
export PATH=${PATH}:/Users/malei/Library/Android/sdk/platform-tools  //       as   
export PATH=${PATH}:/Users/malei/Library/Android/sdk/tools
-------------
maleideMacBook-Pro:~ malei$ source .bash_profile //       
maleideMacBook-Pro:~ malei$ adb devices //        

ステップ2:基本命令
1)接続されたデバイスの表示
    adb devices
2)機器のログの表示
    adb logcat
3)設備の再起動
    adb reboot
4)apkをインストールする
    adb install/Users/storm/temp/demo.apk
5)apkをアンインストールする
    adb uninstall
ステップ3:app crashのとき、再現できません.adbでログを手に入れることができます.
  adb logcat -d >/Users/malei/tt.log(時間がない)
  adb logcat -d -v time >/Users/malei/tt.txt(時間あり)
  adb logcat -v time >/Users/malei/tt.txt(時間があり、リアルタイムでcontrol+cを印刷し続けて停止)
  
ステップ4:プログラムに追加
try {  
      Process process = Runtime.getRuntime().exec("logcat -d");  
      BufferedReader bufferedReader = new BufferedReader(  
      new InputStreamReader(process.getInputStream()));  
  
      StringBuilder log=new StringBuilder();  
      String line;  
      while ((line = bufferedReader.readLine()) != null) {  
        log.append(line);  
      }  
      TextView tv = (TextView)findViewById(R.id.textView1);  
      tv.setText(log.toString());  
    } catch (IOException e) {  
    }