{"id":4042,"date":"2012-09-26T13:41:46","date_gmt":"2012-09-26T16:41:46","guid":{"rendered":"http:\/\/www.telecelula.com.br\/wordpress\/?p=4042"},"modified":"2016-11-18T06:55:55","modified_gmt":"2016-11-18T09:55:55","slug":"o-que-e-adb-e-como-instala-lo","status":"publish","type":"post","link":"https:\/\/www.telecelula.com.br\/wordpress\/?p=4042","title":{"rendered":"O que \u00e9 ADB e como instala-lo?"},"content":{"rendered":"<p><strong>O que \u00e9 ABD ? <\/strong><\/p>\n<p>ADB significa Android Debug Bridge, ele vem de uma parte do Android SDK. B\u00e1sicamente ele d\u00e1 acesso a uma interface via terminal para integra\u00e7\u00e3o entre o usu\u00e1rio e o sistema de arquivo do telefone. Como o Android \u00e9 baseado em Linux as vezes \u00e9 necess\u00e1rio acessar o aparelho via linha de comando para executar certas opera\u00e7\u00f5es avan\u00e7adas em seu aparelho com root.<br \/>\n\u00c9 poss\u00edvel executar esses comandos via alguns aplicativos existentes no pr\u00f3prio Market mas \u00e9 bem complexo executar esses comandos em uma telinha pequena como a do celular. O ADB \u00e9 a interface entre seu computador e o seu celular.<\/p>\n<p>Como Instalar o ADB?<\/p>\n<p>Downloads necess\u00e1rios:<\/p>\n<p>SDK Android SDK Manager v20.0.3<br \/>\nhttp:\/\/www.telecelula.com.br\/new\/suporte_download_arquivo.asp?seguro=4EDA5332C26714999<\/p>\n<p>\u2022 <strong>Passo 1 <\/strong>Instalar o Android SDK<\/p>\n<p>Instalar o Android SDK verifique o link acima para baixar o arquivo em nossa \u00e1rea de download caso nao tenha acesso a nossa \u00e1rea de download acesse: https:\/\/www.telecelula.com.br\/new\/download_Assinar.asp .H\u00e1 vers\u00f5es para Windows, Linux e MacOS X. <strong>O arquivo disponibilizado acima \u00e9 do Windows<\/strong>. Ap\u00f3s o download do SDK, descompacte o arquivo baixado em seu computador, no nosso caso vamos descompactar na raiz do nosso C: e ele ficar\u00e1 em: C:\\android-sdk-windows.<\/p>\n<p>\u2022<strong>Passo 2 <\/strong>Baixando as SDK Platform Tools<\/p>\n<p>Antigamente o ADB j\u00e1 vinha com o SDK platform tools por padr\u00e3o em uma pasta chamada &#8220;tools&#8221; mas agora foi realocado para a subpasta &#8220;platform-tools&#8221; e precisa ser baixado como um pacote SDK<\/p>\n<p>V\u00e1 at\u00e9 a pasta do SDK (C:\\android-sdk-windows) e execute o arquivo SDK Manager (\u00e9 importante estar conectado a internet). Quando executar esse arquivo pela primeira vez, aparecer\u00e1 uma janela para escolher alguns pacotes para instala\u00e7\u00e3o. A primeira op\u00e7\u00e3o \u00e9 &#8220;Android SDK Platform-tools&#8221;, marque-a e DESmarque todos os outros pacotes abaixo. Para marcar\/desmarcar um pacote basta clicar sobre ele e depois clicar na op\u00e7\u00e3o Accept para instalar ou Reject para n\u00e3o instalar.<\/p>\n<p>Depois de selecionar o &#8220;Android SDK Platform-tools&#8221; clique em install e o pacote ser\u00e1 instalado. Assim que o processo terminar voc\u00ea ter\u00e1 a pasta &#8220;platform-tools&#8221;dentro da pasta do SDK (C:\\android-sdk-windows). Essa pasta tem o ADB e suas dependencias.<br \/>\n<strong><br \/>\nPasso 3<\/strong> Adicionando o local do ADB como vari\u00e1vel<\/p>\n<p>Agora que o ADB foi instalado \u00e9 necess\u00e1rio configurar o local onde ele est\u00e1 como uma variavel de ambiente pois assim voc\u00ea n\u00e3o precisa entrar na pasta C:\\android-sdk-windows\\platform-tools\\adb toda vez que for usar o ADB. Vou descrever apenas o m\u00e9todo para o windows pois presumo que seja o sistema que a maioria use no f\u00f3rum.<\/p>\n<p>No Windows 7 clique no &#8220;Windows ORB&#8221; ou no s\u00edmbolo do windows do lado inferior esquerdo da tela, depois clique com o bot\u00e3o direito sobre o \u00edcone &#8220;Computador&#8221; e depois clique em &#8220;Propriedades&#8221;. Nas op\u00e7\u00f5es do lado esquerdo clique em &#8220;Configura\u00e7\u00e3o avan\u00e7ada de Sistemas&#8221;, no windows XP \u00e9 s\u00f3 clicar com o bot\u00e3o direito sobre o &#8220;Meu Computador&#8221; e depois em propriedades.<\/p>\n<p>Na janela que se abrir h\u00e1 uma aba chamada avan\u00e7ada, clique nela e depois h\u00e1 um bot\u00e3o no canto inferior direito da janela chamado &#8220;Vari\u00e1veis de ambiente&#8230;&#8221; clique sobre ele.<\/p>\n<p>Uma nova janela abrir\u00e1, na parte de baixo, em Vari\u00e1veis de Sistema, procure pela vari\u00e1vel Path e de um duplo clique nela.<\/p>\n<p>Uma nova janela abrir\u00e1, N\u00c3O DELETE nada que est\u00e1 l\u00e1, isso pode trazer MUITOS problemas para seu windows.<\/p>\n<p>V\u00e1 at\u00e9 o final do campo &#8220;Valor da Vari\u00e1vel&#8221; e ADICIONE a seguinte linha:<br \/>\n<strong><br \/>\n;c:\\android-sdk-windows\\tools;c:\\android-sdk-windows\\platform-tools<br \/>\n<\/strong><br \/>\n\u2022<strong>Passo 4<\/strong> &#8211; Instalando os drivers USB<\/p>\n<p>Primeiro temos que baixar os drives USB, para isso \u00e9 necess\u00e1rio abrir novamente o SDK Manager que est\u00e1 na pasta SDK e em seguida clicar em &#8220;Available Packages&#8221; no lado esquerdo da janela<\/p>\n<p>Expanda a op\u00e7\u00e3o &#8220;Third party Add-ons&#8221; e depois a op\u00e7\u00e3o &#8220;Google Inc. add-ons&#8221; e marque a op\u00e7\u00e3o &#8220;Google Usb Driver package, revision&#8221; Onde\u00e9 a revis\u00e3o pertinente a aplica\u00e7\u00e3o SDK, a atual \u00e9 4.<\/p>\n<p>Clique em &#8220;Install Selected&#8221; e uma nova janela aparecer\u00e1, clique em &#8220;Accept all&#8221; e depois no bot\u00e3o &#8220;install&#8221;. Aguarde enquanto os drivers s\u00e3o baixados e instalados.<\/p>\n<p>Os drives USB estar\u00e3o na pasta &#8220;<strong>c:\\android-sdk-windows\\extras\\google\\usb_driver\\<\/strong>&#8220;.<\/p>\n<p>Os drivers foram baixados e est\u00e3o prontos para serem instalados. Voc\u00ea pode instala-los em sua m\u00e1quina da seguinte forma:<\/p>\n<p>\u2022 No aparelho, na tela inicial, aperte menu, selecione aplica\u00e7\u00f5es e depois Desenvolvimento, habilite a op\u00e7\u00e3o Depura\u00e7\u00e3o USB<\/p>\n<p>\u2022 Conecte seu aparelho no PC via USB e o windows iniciar\u00e1 uma instala\u00e7\u00e3o de um novo hardware. Caso ele n\u00e3o encontre autom\u00e1ticamente os drivers, fa\u00e7a-o procurar os drivers na pasta onde foram baixados (c:\\android-sdk-windows\\usb_driver) e aguarde a instala\u00e7\u00e3o<\/p>\n<p>\u2022 Assim que os drivers forem instalados voc\u00ea ter\u00e1 uma interface ADB instalada no seu gerenciador de dispositivos Como utilizar o ADB<\/p>\n<p><strong>Como utilizar o ADB <\/strong><\/p>\n<p>Se voc\u00ea seguiu tudo conforme descrito acima e n\u00e3o teve nenhum erro est\u00e1 tudo pronto para a utiliza\u00e7\u00e3o do ADB para manipular seu telefone. A melhor forma de mexer com o ADB \u00e9 pela linha de comando, para certificar-se de que o ADB est\u00e1 instalado corretamente entre no prompt de comando com o seu telefone plugado no computador, digite &#8220;adb devices&#8221; e pressione enter aparecer\u00e1 abaixo o serial number do aparelho.<\/p>\n<p>TABELA DE COMANDOS<\/p>\n<div class=\"jd-descr\">\n<p class=\"table-caption\"><strong>Table 1.<\/strong> Available adb commands<\/p>\n<table>\n<tbody>\n<tr>\n<th>Category<\/th>\n<th>Command<\/th>\n<th>Description<\/th>\n<th>Comments<\/th>\n<\/tr>\n<tr>\n<td rowspan=\"3\">Target Device<\/td>\n<td><code>-d<\/code><\/td>\n<td>Direct an adb command to the only attached USB device.<\/td>\n<td>Returns an error if more than one USB device is attached.<\/td>\n<\/tr>\n<tr>\n<td><code>-e<\/code><\/td>\n<td>Direct an adb command to the only running emulator instance.<\/td>\n<td>Returns an error if more than one emulator instance is running.<\/td>\n<\/tr>\n<tr>\n<td><code>-s\u00a0<var>serial_number<\/var><\/code><\/td>\n<td>Direct an adb command a specific emulator\/device instance, referred to by its adb-assigned serial number (such as &#8220;emulator-5556&#8221;).<\/td>\n<td>See <a href=\"https:\/\/developer.android.com\/studio\/command-line\/adb.html#directingcommands\">Directing Commands to a Specific Emulator\/Device Instance<\/a>.<\/td>\n<\/tr>\n<tr>\n<td rowspan=\"3\">General<\/td>\n<td><code>devices<\/code><\/td>\n<td>Prints a list of all attached emulator\/device instances.<\/td>\n<td>See <a href=\"https:\/\/developer.android.com\/studio\/command-line\/adb.html#devicestatus\">Querying for Emulator\/Device Instances<\/a> for more information.<\/td>\n<\/tr>\n<tr>\n<td><code>help<\/code><\/td>\n<td>Prints a list of supported adb commands.<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td><code>version<\/code><\/td>\n<td>Prints the adb version number.<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td rowspan=\"3\">Debug<\/td>\n<td><code>logcat\u00a0[option] [filter-specs]<\/code><\/td>\n<td>Prints log data to the screen.<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td><code>bugreport<\/code><\/td>\n<td>Prints <code>dumpsys<\/code>, <code>dumpstate<\/code>, and <code>logcat<\/code> data to the screen, for the purposes of bug reporting.<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td><code>jdwp<\/code><\/td>\n<td>Prints a list of available JDWP processes on a given device.<\/td>\n<td>You can use the <code>forward jdwp:<var>pid<\/var><\/code> port-forwarding specification to connect to a specific JDWP process. For example:<br \/>\n<code>adb forward tcp:8000 jdwp:472<\/code><br \/>\n<code>jdb -attach localhost:8000<\/code><\/td>\n<\/tr>\n<tr>\n<td rowspan=\"3\">Data<\/td>\n<td><code>install\u00a0<var>path_to_apk<\/var><\/code><\/td>\n<td>Pushes an Android application (specified as a full path to an APK file) to an emulator\/device.<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td><code>pull\u00a0<var>remote<\/var>\u00a0<var>local<\/var><\/code><\/td>\n<td>Copies a specified file from an emulator\/device instance to your development computer.<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td><code>push\u00a0<var>local<\/var>\u00a0<var>remote<\/var><\/code><\/td>\n<td>Copies a specified file from your development computer to an emulator\/device instance.<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td rowspan=\"2\">Ports and Networking<\/td>\n<td><code>forward\u00a0<var>local<\/var>\u00a0<var>remote<\/var><\/code><\/td>\n<td>Forwards socket connections from a specified local port to a specified remote port on the emulator\/device instance.<\/td>\n<td>Port specifications can use these schemes:<\/p>\n<ul>\n<li><code>tcp:<var>port_number<\/var><\/code><\/li>\n<li><code>local:<var>unix_domain_socket_name<\/var><\/code><\/li>\n<li><code>dev:<var>character_device_name<\/var><\/code><\/li>\n<li><code>jdwp:<var>pid<\/var><\/code><\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<tr>\n<td><code>ppp\u00a0<var>tty<\/var>\u00a0[parm]...<\/code><\/td>\n<td>Run PPP over USB.<\/p>\n<ul>\n<li><code><var>tty<\/var><\/code> \u2014 the tty for PPP stream. For example <code>dev:\/dev\/omap_csmi_ttyl<\/code>.<\/li>\n<li><code>[parm]... <\/code>\u2014 zero or more PPP\/PPPD options, such as <code>defaultroute<\/code>, <code>local<\/code>, <code>notty<\/code>, etc.<\/li>\n<\/ul>\n<p>Note that you should not automatically start a PPP connection.<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td rowspan=\"3\">Scripting<\/td>\n<td><code>get-serialno<\/code><\/td>\n<td>Prints the adb instance serial number string.<\/td>\n<td rowspan=\"2\">See <a href=\"https:\/\/developer.android.com\/studio\/command-line\/adb.html#devicestatus\">Querying for Emulator\/Device Instances<\/a> for more information.<\/td>\n<\/tr>\n<tr>\n<td><code>get-state<\/code><\/td>\n<td>Prints the adb state of an emulator\/device instance.<\/td>\n<\/tr>\n<tr>\n<td><code>wait-for-device<\/code><\/td>\n<td>Blocks execution until the device is online \u2014 that is, until the instance state is <code>device<\/code>.<\/td>\n<td>You can prepend this command to other adb commands, in which case adb will wait until the emulator\/device instance is connected before issuing the other commands. Here&#8217;s an example:<\/p>\n<pre class=\"no-pretty-print\">adb wait-for-device shell getprop<\/pre>\n<p>Note that this command does <em>not<\/em> cause adb to wait until the entire system is fully booted. For that reason, you should not prepend it to other commands that require a fully booted system. As an example, the <code>install<\/code> requires the Android package manager, which is available only after the system is fully booted. A command such as<\/p>\n<pre class=\"no-pretty-print\">adb wait-for-device install app.apk<\/pre>\n<p>would issue the <code>install<\/code> command as soon as the emulator or device instance connected to the adb server, but before the Android system was fully booted, so it would result in an error.<\/td>\n<\/tr>\n<tr>\n<td rowspan=\"2\">Server<\/td>\n<td><code>start-server<\/code><\/td>\n<td>Checks whether the adb server process is running and starts it, if not.<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td><code>kill-server<\/code><\/td>\n<td>Terminates the adb server process.<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td rowspan=\"2\">Shell<\/td>\n<td><code>shell<\/code><\/td>\n<td>Starts a remote shell in the target emulator\/device instance.<\/td>\n<td rowspan=\"2\">See <a href=\"https:\/\/developer.android.com\/studio\/command-line\/adb.html#shellcommands\">Issue shell commands<\/a> for more information.<\/td>\n<\/tr>\n<tr>\n<td><code>shell\u00a0<var>shell_command<\/var><\/code><\/td>\n<td>Issues a shell command in the target emulator\/device instance and then exits the remote shell.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2 id=\"shellcommands\">Issue shell commands<\/h2>\n<hr \/>\n<p>You can use the <code>shell<\/code> command to issue device commands through adb, with or without entering the adb remote shell on the emulator\/device. To issue a single command without entering a remote shell, use the <code>shell<\/code> command like this:<\/p>\n<pre class=\"no-pretty-print\">adb [-d|-e|-s <var>serial_number<\/var>] shell <var>shell_command<\/var><\/pre>\n<p>Or enter a remote shell on an emulator\/device like this:<\/p>\n<pre class=\"no-pretty-print\">adb [-d|-e|-s <var>serial_number<\/var>] shell<\/pre>\n<p>When you are ready to exit the remote shell, press Control + D or type <code>exit<\/code>.<\/p>\n<p>The shell command binaries are stored in the file system of the emulator or device, at <code>\/system\/bin\/<\/code>.<\/p>\n<h3 id=\"am\">Call activity manager (<code>am<\/code>)<\/h3>\n<p>Within an adb shell, you can issue commands with the activity manager (<code>am<\/code>) tool to perform various system actions, such as start an activity, force-stop a process, broadcast an intent, modify the device screen properties, and more. While in a shell, the syntax is:<\/p>\n<pre class=\"no-pretty-print\">am <var>command<\/var>\r\n<\/pre>\n<p>You can also issue an activity manager command directly from adb without entering a remote shell. For example:<\/p>\n<pre class=\"no-pretty-print\">adb shell am start -a android.intent.action.VIEW\r\n<\/pre>\n<p class=\"table-caption\"><strong>Table 2.<\/strong> Available activity manager commands<\/p>\n<table>\n<tbody>\n<tr>\n<th>Command<\/th>\n<th>Description<\/th>\n<\/tr>\n<tr>\n<td><code>start [<var>options<\/var>] <var>intent<\/var><\/code><\/td>\n<td>Start an <code><a href=\"https:\/\/developer.android.com\/reference\/android\/app\/Activity.html\">Activity<\/a><\/code> specified by <code><var>intent<\/var><\/code>.See the <a href=\"https:\/\/developer.android.com\/studio\/command-line\/adb.html#IntentSpec\">Specification for intent arguments<\/a>.<\/p>\n<p>Options are:<\/p>\n<ul>\n<li><code>-D<\/code>: Enable debugging.<\/li>\n<li><code>-W<\/code>: Wait for launch to complete.<\/li>\n<li><code>--start-profiler <var>file<\/var><\/code>: Start profiler and send results to <code><var>file<\/var><\/code>.<\/li>\n<li><code>-P <var>file<\/var><\/code>: Like <code>--start-profiler<\/code>, but profiling stops when the app goes idle.<\/li>\n<li><code>-R <var>count<\/var><\/code>: Repeat the activity launch <code><var>count<\/var><\/code> times. Prior to each repeat, the top activity will be finished.<\/li>\n<li><code>-S<\/code>: Force stop the target app before starting the activity.<\/li>\n<li><code>--opengl-trace<\/code>: Enable tracing of OpenGL functions.<\/li>\n<li><code>--user <var>user_id<\/var> | current<\/code>: Specify which user to run as; if not specified, then run as the current user.<\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<tr>\n<td><code>startservice [<var>options<\/var>] <var>intent<\/var><\/code><\/td>\n<td>Start the <code><a href=\"https:\/\/developer.android.com\/reference\/android\/app\/Service.html\">Service<\/a><\/code> specified by <code><var>intent<\/var><\/code>.See the <a href=\"https:\/\/developer.android.com\/studio\/command-line\/adb.html#IntentSpec\">Specification for intent arguments<\/a>.<\/p>\n<p>Options are:<\/p>\n<ul>\n<li><code>--user <var>user_id<\/var> | current<\/code>: Specify which user to run as; if not specified, then run as the current user.<\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<tr>\n<td><code>force-stop <var>package<\/var><\/code><\/td>\n<td>Force stop everything associated with <code><var>package<\/var><\/code> (the app&#8217;s package name).<\/td>\n<\/tr>\n<tr>\n<td><code>kill [<var>options<\/var>] <var>package<\/var><\/code><\/td>\n<td>Kill all processes associated with <code><var>package<\/var><\/code> (the app&#8217;s package name). This command kills only processes that are safe to kill and that will not impact the user experience.Options are:<\/p>\n<ul>\n<li><code>--user <var>user_id<\/var> | all | current<\/code>: Specify user whose processes to kill; all users if not specified.<\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<tr>\n<td><code>kill-all<\/code><\/td>\n<td>Kill all background processes.<\/td>\n<\/tr>\n<tr>\n<td><code>broadcast [<var>options<\/var>] <var>intent<\/var><\/code><\/td>\n<td>Issue a broadcast intent.See the <a href=\"https:\/\/developer.android.com\/studio\/command-line\/adb.html#IntentSpec\">Specification for intent arguments<\/a>.<\/p>\n<p>Options are:<\/p>\n<ul>\n<li><code>[--user <var>user_id<\/var> | all | current]<\/code>: Specify which user to send to; if not specified then send to all users.<\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<tr>\n<td><code>instrument [<var>options<\/var>] <var>component<\/var><\/code><\/td>\n<td>Start monitoring with an <code><a href=\"https:\/\/developer.android.com\/reference\/android\/app\/Instrumentation.html\">Instrumentation<\/a><\/code> instance. Typically the target <code><var>component<\/var><\/code> is the form <code><var>test_package<\/var>\/<var>runner_class<\/var><\/code>.Options are:<\/p>\n<ul>\n<li><code>-r<\/code>: Print raw results (otherwise decode <code><var>report_key_streamresult<\/var><\/code>). Use with <code>[-e perf true]<\/code> to generate raw output for performance measurements.<\/li>\n<li><code>-e <var>name<\/var> <var>value<\/var><\/code>: Set argument <code><var>name<\/var><\/code> to <code><var>value<\/var><\/code>. For test runners a common form is <code>-e <var>testrunner_flag<\/var><var>value<\/var>[,<var>value<\/var>...]<\/code>.<\/li>\n<li><code>-p <var>file<\/var><\/code>: Write profiling data to <code><var>file<\/var><\/code>.<\/li>\n<li><code>-w<\/code>: Wait for instrumentation to finish before returning. Required for test runners.<\/li>\n<li><code>--no-window-animation<\/code>: Turn off window animations while running.<\/li>\n<li><code>--user <var>user_id<\/var> | current<\/code>: Specify which user instrumentation runs in; current user if not specified.<\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<tr>\n<td><code>profile start <var>process<\/var> <var>file<\/var><\/code><\/td>\n<td>Start profiler on <code><var>process<\/var><\/code>, write results to <code><var>file<\/var><\/code>.<\/td>\n<\/tr>\n<tr>\n<td><code>profile stop <var>process<\/var><\/code><\/td>\n<td>Stop profiler on <code><var>process<\/var><\/code>.<\/td>\n<\/tr>\n<tr>\n<td><code>dumpheap [<var>options<\/var>] <var>process<\/var> <var>file<\/var><\/code><\/td>\n<td>Dump the heap of <code><var>process<\/var><\/code>, write to <code><var>file<\/var><\/code>.Options are:<\/p>\n<ul>\n<li><code>--user [<var>user_id<\/var>|current]<\/code>: When supplying a process name, specify user of process to dump; uses current user if not specified.<\/li>\n<li><code>-n<\/code>: Dump native heap instead of managed heap.<\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<tr>\n<td><code>set-debug-app [<var>options<\/var>] <var>package<\/var><\/code><\/td>\n<td>Set application <code><var>package<\/var><\/code> to debug.Options are:<\/p>\n<ul>\n<li><code>-w<\/code>: Wait for debugger when application starts.<\/li>\n<li><code>--persistent<\/code>: Retain this value.<\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<tr>\n<td><code>clear-debug-app<\/code><\/td>\n<td>Clear the package previous set for debugging with <code>set-debug-app<\/code>.<\/td>\n<\/tr>\n<tr>\n<td><code>monitor [<var>options<\/var>]<\/code><\/td>\n<td>Start monitoring for crashes or ANRs.Options are:<\/p>\n<ul>\n<li><code>--gdb<\/code>: Start gdbserv on the given port at crash\/ANR.<\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<tr>\n<td><code>screen-compat {on|off} <var>package<\/var><\/code><\/td>\n<td>Control <a href=\"https:\/\/developer.android.com\/guide\/practices\/screen-compat-mode.html\">screen compatibility<\/a> mode of <code><var>package<\/var><\/code>.<\/td>\n<\/tr>\n<tr>\n<td><code>display-size [reset|<var>width<\/var>x<var>height<\/var>]<\/code><\/td>\n<td>Override emulator\/device display size. This command is helpful for testing your app across different screen sizes by mimicking a small screen resolution using a device with a large screen, and vice versa.Example:<br \/>\n<code>am display-size 1280x800<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>display-density <var>dpi<\/var><\/code><\/td>\n<td>Override emulator\/device display density. This command is helpful for testing your app across different screen densities on high-density screen environment using a low density screen, and vice versa.Example:<br \/>\n<code>am display-density 480<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>to-uri <var>intent<\/var><\/code><\/td>\n<td>Print the given intent specification as a URI.See the <a href=\"https:\/\/developer.android.com\/studio\/command-line\/adb.html#IntentSpec\">Specification for intent arguments<\/a>.<\/td>\n<\/tr>\n<tr>\n<td><code>to-intent-uri <var>intent<\/var><\/code><\/td>\n<td>Print the given intent specification as an <code>intent:<\/code> URI.See the <a href=\"https:\/\/developer.android.com\/studio\/command-line\/adb.html#IntentSpec\">Specification for intent arguments<\/a>.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4 id=\"IntentSpec\"><a class=\"expandable\" href=\"https:\/\/developer.android.com\/\">Specification for intent arguments<\/a><\/h4>\n<h3 id=\"pm\">Call package manager (<code>pm<\/code>)<\/h3>\n<p>Within an adb shell, you can issue commands with the package manager (<code>pm<\/code>) tool to perform actions and queries on application packages installed on the device. While in a shell, the syntax is:<\/p>\n<pre class=\"no-pretty-print\">pm <var>command<\/var>\r\n<\/pre>\n<p>You can also issue a package manager command directly from adb without entering a remote shell. For example:<\/p>\n<pre class=\"no-pretty-print\">adb shell pm uninstall com.example.MyApp\r\n<\/pre>\n<p class=\"table-caption\"><strong>Table 3.<\/strong> Available package manager commands.<\/p>\n<table>\n<tbody>\n<tr>\n<th>Command<\/th>\n<th>Description<\/th>\n<\/tr>\n<tr>\n<td><code>list packages [<var>options<\/var>] <var>filter<\/var><\/code><\/td>\n<td>Prints all packages, optionally only those whose package name contains the text in <code><var>filter<\/var><\/code>.Options:<\/p>\n<ul>\n<li><code>-f<\/code>: See their associated file.<\/li>\n<li><code>-d<\/code>: Filter to only show disabled packages.<\/li>\n<li><code>-e<\/code>: Filter to only show enabled packages.<\/li>\n<li><code>-s<\/code>: Filter to only show system packages.<\/li>\n<li><code>-3<\/code>: Filter to only show third party packages.<\/li>\n<li><code>-i<\/code>: See the installer for the packages.<\/li>\n<li><code>-u<\/code>: Also include uninstalled packages.<\/li>\n<li><code>--user <var>user_id<\/var><\/code>: The user space to query.<\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<tr>\n<td><code>list permission-groups<\/code><\/td>\n<td>Prints all known permission groups.<\/td>\n<\/tr>\n<tr>\n<td><code>list permissions [<var>options<\/var>] <var>group<\/var><\/code><\/td>\n<td>Prints all known permissions, optionally only those in <code><var>group<\/var><\/code>.Options:<\/p>\n<ul>\n<li><code>-g<\/code>: Organize by group.<\/li>\n<li><code>-f<\/code>: Print all information.<\/li>\n<li><code>-s<\/code>: Short summary.<\/li>\n<li><code>-d<\/code>: Only list dangerous permissions.<\/li>\n<li><code>-u<\/code>: List only the permissions users will see.<\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<tr>\n<td><code>list instrumentation [<var>options<\/var>]<\/code><\/td>\n<td>List all test packages.Options:<\/p>\n<ul>\n<li><code>-f<\/code>: List the APK file for the test package.<\/li>\n<li><code><var>target_package<\/var><\/code>: List test packages for only this app.<\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<tr>\n<td><code>list features<\/code><\/td>\n<td>Prints all features of the system.<\/td>\n<\/tr>\n<tr>\n<td><code>list libraries<\/code><\/td>\n<td>Prints all the libraries supported by the current device.<\/td>\n<\/tr>\n<tr>\n<td><code>list users<\/code><\/td>\n<td>Prints all users on the system.<\/td>\n<\/tr>\n<tr>\n<td><code>path <var>package<\/var><\/code><\/td>\n<td>Print the path to the APK of the given <code><var>package<\/var><\/code>.<\/td>\n<\/tr>\n<tr>\n<td><code>install [<var>options<\/var>] <var>path<\/var><\/code><\/td>\n<td>Installs a package (specified by <code><var>path<\/var><\/code>) to the system.Options:<\/p>\n<ul>\n<li><code>-l<\/code>: Install the package with forward lock.<\/li>\n<li><code>-r<\/code>: Reinstall an existing app, keeping its data.<\/li>\n<li><code>-t<\/code>: Allow test APKs to be installed.<\/li>\n<li><code>-i <var>installer_package_name<\/var><\/code>: Specify the installer package name.<\/li>\n<li><code>-s<\/code>: Install package on the shared mass storage (such as sdcard).<\/li>\n<li><code>-f<\/code>: Install package on the internal system memory.<\/li>\n<li><code>-d<\/code>: Allow version code downgrade.<\/li>\n<li><code>-g<\/code>: Grant all permissions listed in the app manifest.<\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<tr>\n<td><code>uninstall [<var>options<\/var>] <var>package<\/var><\/code><\/td>\n<td>Removes a package from the system.Options:<\/p>\n<ul>\n<li><code>-k<\/code>: Keep the data and cache directories around after package removal.<\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<tr>\n<td><code>clear <var>package<\/var><\/code><\/td>\n<td>Deletes all data associated with a package.<\/td>\n<\/tr>\n<tr>\n<td><code>enable <var>package_or_component<\/var><\/code><\/td>\n<td>Enable the given package or component (written as &#8220;package\/class&#8221;).<\/td>\n<\/tr>\n<tr>\n<td><code>disable <var>package_or_component<\/var><\/code><\/td>\n<td>Disable the given package or component (written as &#8220;package\/class&#8221;).<\/td>\n<\/tr>\n<tr>\n<td><code>disable-user [<var>options<\/var>] <var>package_or_component<\/var><\/code><\/td>\n<td>Options:<\/p>\n<ul>\n<li><code>--user <var>user_id<\/var><\/code>: The user to disable.<\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<tr>\n<td><code>grant <var>package_name<\/var> <var>permission<\/var><\/code><\/td>\n<td>Grant a permission to an app. On devices running Android 6.0 (API level 23) and higher, may be any permission declared in the app manifest. On devices running Android 5.1 (API level 22) and lower, must be an optional permission defined by the app.<\/td>\n<\/tr>\n<tr>\n<td><code>revoke <var>package_name<\/var> <var>permission<\/var><\/code><\/td>\n<td>Revoke a permission from an app. On devices running Android 6.0 (API level 23) and higher, may be any permission declared in the app manifest. On devices running Android 5.1 (API level 22) and lower, must be an optional permission defined by the app.<\/td>\n<\/tr>\n<tr>\n<td><code>set-install-location <var>location<\/var><\/code><\/td>\n<td>Changes the default install location. Location values:<\/p>\n<ul>\n<li><code>0<\/code>: Auto\u2014Let system decide the best location.<\/li>\n<li><code>1<\/code>: Internal\u2014install on internal device storage.<\/li>\n<li><code>2<\/code>: External\u2014install on external media.<\/li>\n<\/ul>\n<p class=\"note\"><strong>Note:<\/strong> This is only intended for debugging; using this can cause applications to break and other undesireable behavior.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td><code>get-install-location<\/code><\/td>\n<td>Returns the current install location. Return values:<\/p>\n<ul>\n<li><code>0 [auto]<\/code>: Lets system decide the best location<\/li>\n<li><code>1 [internal]<\/code>: Installs on internal device storage<\/li>\n<li><code>2 [external]<\/code>: Installs on external media<\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<tr>\n<td><code>set-permission-enforced <var>permission<\/var>[true|false]<\/code><\/td>\n<td>Specifies whether the given permission should be enforced.<\/td>\n<\/tr>\n<tr>\n<td><code>trim-caches <var>desired_free_space<\/var><\/code><\/td>\n<td>Trim cache files to reach the given free space.<\/td>\n<\/tr>\n<tr>\n<td><code>create-user <var>user_name<\/var><\/code><\/td>\n<td>Create a new user with the given <code><var>user_name<\/var><\/code>, printing the new user identifier of the user.<\/td>\n<\/tr>\n<tr>\n<td><code>remove-user <var>user_id<\/var><\/code><\/td>\n<td>Remove the user with the given <code><var>user_id<\/var><\/code>, deleting all data associated with that user<\/td>\n<\/tr>\n<tr>\n<td><code>get-max-users<\/code><\/td>\n<td>Prints the maximum number of users supported by the device.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3 id=\"screencap\">Take a screenshot<\/h3>\n<p>The <code>screencap<\/code> command is a shell utility for taking a screenshot of a device display. While in a shell, the syntax is:<\/p>\n<pre class=\"no-pretty-print\">screencap <var>filename<\/var>\r\n<\/pre>\n<p>To use the <code>screencap<\/code> from the command line, type the following:<\/p>\n<pre class=\"prettyprint\"><span class=\"pln\">$ adb shell screencap <\/span><span class=\"pun\">\/<\/span><span class=\"pln\">sdcard<\/span><span class=\"pun\">\/<\/span><span class=\"pln\">screen<\/span><span class=\"pun\">.<\/span><span class=\"pln\">png<\/span><\/pre>\n<p>Here&#8217;s an example screenshot session, using the adb shell to capture the screenshot and the <code>pull<\/code> command to download the file from the device:<\/p>\n<pre class=\"prettyprint\"><span class=\"pln\">$ adb shell\r\nshell@ $ screencap <\/span><span class=\"pun\">\/<\/span><span class=\"pln\">sdcard<\/span><span class=\"pun\">\/<\/span><span class=\"pln\">screen<\/span><span class=\"pun\">.<\/span><span class=\"pln\">png\r\nshell@ $ <\/span><span class=\"kwd\">exit<\/span><span class=\"pln\">\r\n$ adb pull <\/span><span class=\"pun\">\/<\/span><span class=\"pln\">sdcard<\/span><span class=\"pun\">\/<\/span><span class=\"pln\">screen<\/span><span class=\"pun\">.<\/span><span class=\"pln\">png<\/span><\/pre>\n<h3 id=\"screenrecord\">Record a video<\/h3>\n<p>The <code>screenrecord<\/code> command is a shell utility for recording the display of devices running Android 4.4 (API level 19) and higher. The utility records screen activity to an MPEG-4 file.<\/p>\n<p class=\"note\"><strong>Note:<\/strong> Audio is not recorded with the video file.<\/p>\n<p>A developer can use this file to create promotional or training videos. While in a shell, the syntax is:<\/p>\n<pre class=\"no-pretty-print\">screenrecord [<var>options<\/var>] <var>filename<\/var>\r\n<\/pre>\n<p>To use <code>screenrecord<\/code> from the command line, type the following:<\/p>\n<pre class=\"prettyprint\"><span class=\"pln\">$ adb shell screenrecord <\/span><span class=\"pun\">\/<\/span><span class=\"pln\">sdcard<\/span><span class=\"pun\">\/<\/span><span class=\"pln\">demo<\/span><span class=\"pun\">.<\/span><span class=\"pln\">mp4<\/span><\/pre>\n<p>Stop the screen recording by pressing Control + C, otherwise the recording stops automatically at three minutes or the time limit set by <code>--time-limit<\/code>.<\/p>\n<p>To begin recording your device screen, run the <code>screenrecord<\/code> command to record the video. Then, run the <code>pull<\/code> command to download the video from the device to the host computer. Here&#8217;s an example recording session:<\/p>\n<pre class=\"prettyprint\"><span class=\"pln\">$ adb shell\r\nshell@ $ screenrecord <\/span><span class=\"pun\">--<\/span><span class=\"pln\">verbose <\/span><span class=\"pun\">\/<\/span><span class=\"pln\">sdcard<\/span><span class=\"pun\">\/<\/span><span class=\"pln\">demo<\/span><span class=\"pun\">.<\/span><span class=\"pln\">mp4\r\n<\/span><span class=\"pun\">(<\/span><span class=\"pln\">press <\/span><span class=\"typ\">Control<\/span> <span class=\"pun\">+<\/span><span class=\"pln\"> C to stop<\/span><span class=\"pun\">)<\/span><span class=\"pln\">\r\nshell@ $ <\/span><span class=\"kwd\">exit<\/span><span class=\"pln\">\r\n$ adb pull <\/span><span class=\"pun\">\/<\/span><span class=\"pln\">sdcard<\/span><span class=\"pun\">\/<\/span><span class=\"pln\">demo<\/span><span class=\"pun\">.<\/span><span class=\"pln\">mp4<\/span><\/pre>\n<p>The <code>screenrecord<\/code> utility can record at any supported resolution and bit rate you request, while retaining the aspect ratio of the device display. The utility records at the native display resolution and orientation by default, with a maximum length of three minutes.<\/p>\n<p>There are some known limitations of the <code>screenrecord<\/code> utility that you should be aware of when using it:<\/p>\n<ul>\n<li>Some devices may not be able to record at their native display resolution. If you encounter problems with screen recording, try using a lower screen resolution.<\/li>\n<li>Rotation of the screen during recording is not supported. If the screen does rotate during recording, some of the screen is cut off in the recording.<\/li>\n<\/ul>\n<p class=\"table-caption\"><strong>Table 4.<\/strong> <code>screenrecord<\/code> options<\/p>\n<table>\n<tbody>\n<tr>\n<th>Options<\/th>\n<th>Description<\/th>\n<\/tr>\n<tr>\n<td><code>--help<\/code><\/td>\n<td>Displays command syntax and options<\/td>\n<\/tr>\n<tr>\n<td><code>--size <var>width<\/var>x<var>height<\/var><\/code><\/td>\n<td>Sets the video size: <code>1280x720<\/code>. The default value is the device&#8217;s native display resolution (if supported), 1280&#215;720 if not. For best results, use a size supported by your device&#8217;s Advanced Video Coding (AVC) encoder.<\/td>\n<\/tr>\n<tr>\n<td><code>--bit-rate <var>rate<\/var><\/code><\/td>\n<td>Sets the video bit rate for the video, in megabits per second. The default value is 4Mbps. You can increase the bit rate to improve video quality, but doing so results in larger movie files. The following example sets the recording bit rate to 6Mbps:<\/p>\n<pre class=\"prettyprint\"><span class=\"pln\">screenrecord <\/span><span class=\"pun\">--<\/span><span class=\"pln\">bit<\/span><span class=\"pun\">-<\/span><span class=\"pln\">rate <\/span><span class=\"lit\">6000000<\/span> <span class=\"pun\">\/<\/span><span class=\"pln\">sdcard<\/span><span class=\"pun\">\/<\/span><span class=\"pln\">demo<\/span><span class=\"pun\">.<\/span><span class=\"pln\">mp4<\/span><\/pre>\n<\/td>\n<\/tr>\n<tr>\n<td><code>--time-limit <var>time<\/var><\/code><\/td>\n<td>Sets the maximum recording time, in seconds. The default and maximum value is 180 (3 minutes).<\/td>\n<\/tr>\n<tr>\n<td><code>--rotate<\/code><\/td>\n<td>Rotates the output 90 degrees. This feature is experimental.<\/td>\n<\/tr>\n<tr>\n<td><code>--verbose<\/code><\/td>\n<td>Displays log information on the command-line screen. If you do not set this option, the utility does not display any information while running.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3 id=\"appprofiles\">Read ART profiles for apps<\/h3>\n<p>Starting in Android 7.0 (API level 24) the Android Runtime (ART) collects execution profiles for installed apps, which are used to optimize app performance. You might want to examine the collected profiles to understand which methods are determined to be frequently executed and which classes are used during app startup.<\/p>\n<p>To produce a text form of the profile information, use the command:<\/p>\n<pre class=\"no-pretty-print\">$ adb shell cmd package dump-profiles <var>package<\/var>\r\n<\/pre>\n<p>To retrieve the file produced, use:<\/p>\n<pre class=\"no-pretty-print\">$ adb pull \/data\/misc\/profman\/<var>package<\/var>.txt\r\n<\/pre>\n<h3 id=\"othershellcommands\">Other shell commands<\/h3>\n<p>For a list of all the available shell programs, use the following command:<\/p>\n<pre class=\"no-pretty-print\">adb shell ls \/system\/bin<\/pre>\n<p>Help is available for most of the commands.<\/p>\n<p>Table 5 lists some of the more common adb shell commands.<\/p>\n<p class=\"table-caption\"><strong>Table 5.<\/strong> Some other adb shell commands<\/p>\n<table>\n<tbody>\n<tr>\n<th>Shell Command<\/th>\n<th>Description<\/th>\n<th>Comments<\/th>\n<\/tr>\n<tr>\n<td><code>dumpsys<\/code><\/td>\n<td>Dumps system data to the screen.<\/td>\n<td rowspan=\"4\">The <a href=\"https:\/\/developer.android.com\/studio\/profile\/ddms.html\">Dalvik Debug Monitor Server<\/a> (DDMS) tool offers an integrated debug environment that you may find easier to use.<\/td>\n<\/tr>\n<tr>\n<td><code>dumpstate<\/code><\/td>\n<td>Dumps state to a file.<\/td>\n<\/tr>\n<tr>\n<td><code>logcat\u00a0[option]...\u00a0[filter-spec]...<\/code><\/td>\n<td>Enables system and app logging and prints output to the screen.<\/td>\n<\/tr>\n<tr>\n<td><code>dmesg<\/code><\/td>\n<td>Prints kernel debugging messages to the screen.<\/td>\n<\/tr>\n<tr>\n<td><code>start<\/code><\/td>\n<td>Starts (restarts) an emulator\/device instance.<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td><code>stop<\/code><\/td>\n<td>Stops execution of an emulator\/device instance.<\/td>\n<td><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<div class=\"wrap\"><\/div>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>O que \u00e9 ABD ? ADB significa Android Debug Bridge, ele vem de uma parte do Android SDK. B\u00e1sicamente ele d\u00e1 acesso a uma interface via terminal para integra\u00e7\u00e3o entre o usu\u00e1rio e o sistema de arquivo do telefone. Como o Android \u00e9 baseado em Linux as vezes \u00e9 necess\u00e1rio acessar o aparelho via linha [&hellip;]<\/p>\n","protected":false},"author":17,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[121,47,288],"tags":[],"class_list":{"0":"post-4042","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-android-manutencao-em-celulares","7":"category-samsung","8":"category-smartphones","9":"czr-hentry"},"_links":{"self":[{"href":"https:\/\/www.telecelula.com.br\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/4042","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.telecelula.com.br\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.telecelula.com.br\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.telecelula.com.br\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/17"}],"replies":[{"embeddable":true,"href":"https:\/\/www.telecelula.com.br\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4042"}],"version-history":[{"count":5,"href":"https:\/\/www.telecelula.com.br\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/4042\/revisions"}],"predecessor-version":[{"id":7048,"href":"https:\/\/www.telecelula.com.br\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/4042\/revisions\/7048"}],"wp:attachment":[{"href":"https:\/\/www.telecelula.com.br\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4042"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.telecelula.com.br\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4042"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.telecelula.com.br\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4042"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}