31

コマンド プロンプトから正常にエミュレータを停止できません。

Linux Ubuntu v10.04 (64 ビット) と Android v2.3 (API 9 - Gingerbread) を使用しています。

スナップショットを使用してエミュレータを起動しました。今、私の懸念は、エミュレーターの実行中のインスタンスを正常にシャットダウンすることです。(エミュレーター実行中のプロセス ID)を試してみましkill -9たが、エミュレーターをシャットダウンしましたが、スナップショットが破損したため、次回は起動しません。エミュレーターの強制シャットダウンを回避するのを手伝ってください。

それを修正する方法はありますか?

4

3 に答える 3

64

無差別に使用しないでくださいkill -9。非常に悪い習慣です。

正しいコマンドは

 $ adb emu kill

または、最近の変更までは正しいコマンドだったと言ったほうがよいでしょう。adb誰かが認証を追加するのを忘れたようです。

最新(2016年6月現在)の最新adbバージョンは

$ adb version
Android Debug Bridge version 1.0.36
Revision 0a04cdc4a62f-android

そして試してみると

$ adb emu kill

何も起こりません、これが理由です

...
connect(3, {sa_family=AF_INET, sin_port=htons(5554), 
sin_addr=inet_addr("127.0.0.1")}, 16) = 0
write(3, "kill\nquit\n", 10)            = 10
read(3, "\377\373\1", 8192)             = 3
read(3, "\377\373\3\377\373\0\377\375\0", 8192) = 9
read(3, "Android Console: Authentication required\r\nAndroid Console: type 'auth <auth_token>' to authenticate\r\nAndroid Console: you can find your <auth_token> in \r\n'/home/diego/.emulator_console_auth_token'\r\nOK\r\n", 8192) = 202
read(3, "k\33[K", 8192)                 = 4
read(3, "\33[Dki\33[K", 8192)           = 8
read(3, "\33[D\33[Dkil\33[K\33[D\33[D\33[Dkill\33[K", 8192) = 28
read(3, "\r\nKO: unknown command, try 'help'\r\n", 8192) = 35
read(3, "q\33[K\33[Dqu\33[K", 8192)     = 12
read(3, "\33[D\33[Dqui\33[K\33[D\33[D\33[Dquit\33[K", 8192) = 28
read(3, "\r\n", 8192)                   = 2
read(3, "", 8192)                       = 0
close(3)                                = 0
exit_group(0)                           = ?
+++ exited with 0 +++

次に、別の解決策が必要です。

前のコマンドが機能しない場合 (一部のユーザーが Windows で報告したように)、試すことができます (次のコマンドで 5554 はエミュレータが使用するポートです)。

トークン ファイル ( ~/.emulator_console_auth_token) の内容をクリップボードにコピーして、Telnet セッション中に貼り付けることができるようにします。

$ telnet localhost 5554

Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Android Console: Authentication required
Android Console: type 'auth <auth_token>' to authenticate
Android Console: you can find your <auth_token> in 
'/home/user/.emulator_console_auth_token'
OK
auth <YOUR_TOKEN_HERE>
Android Console: type 'help' for a list of commands
OK
Android console command help:

    help|h|?         print a list of commands
    crash            crash the emulator instance
    kill             kill the emulator instance
    quit|exit        quit control session
    redir            manage port redirections
    power            power related commands
    event            simulate hardware events
    avd              control virtual device execution
    finger           manage emulator fingerprint
    geo              Geo-location commands
    sms              SMS related commands
    cdma             CDMA related commands
    gsm              GSM related commands
    rotate           rotate the screen by 90 degrees

try 'help <command>' for command-specific help
OK

kill次に、コマンドプロンプトで入力するだけです

kill
OK: killing emulator, bye bye
Connection closed by foreign host.

エミュレータが終了します。

しかし、待ってください。もっと良い方法があるはずです。そして実際にあります!

この要点は、毎回認証トークンをカットアンドパスする代わりに、expectを使用して自動化されたソリューションを提供します。

お役に立てば幸いです。

于 2011-05-06T14:22:55.897 に答える
0

Ubuntu 16-04 では、ADB バージョン 1.0.32 を使用して、docker コンテナーで Android 4.4 (API 19) のエミュレーターを実行しています。公開されているポートは、コンソール用に 30004、ADB 用に 30005 です。

を実行することで接続できadb connect 0.0.0.0:30005ます。

ただし、エミュレーターを強制終了するには、を使用する必要がありadb -s emulator-30004 emu kill、使用すると0.0.0.0:30005が得られますerror: no emulator detected

于 2017-01-12T02:15:46.850 に答える