Skip to main content

Featured

Android studio “SDK tools directory is missing”

Following 2 possible solutions will resolve this problem :  Solution1 : To fix the problem, it was required that I list the path to my corporate PAC file by using  Configure -> "Appearance and Behavior" -> System Settings -> HTTP Proxy . I selected "Automatic proxy configuration url:" Delete your  ~/.Android*  folders (losing all of your settings :/). Run Android Studio. It will show you a welcome wizard where it tries to download the SDK again (and fails due to my rubbish internet). Click the X on the wizard window. That will enable you to get to the normal welcome dialog. Go to Settings->Project Defaults->Project Structure and change the Android SDK location to the correct one. Solution 2 : To fix the problem, it was required that I list the path to my corporate PAC file by using  Configure -> "Appearance and Behavior" -> System Settings -> HTTP Proxy . I selected "Automatic proxy configuration url:...

using adb(Android Debug Bridge) commands,in Android

You can find the adb tool in <sdk>/platform-tools/.
For easy access, add this path to PATH env variable.
Linux,
>export PATH=.:$PATH

Windows:
append <sdk>/platform-tools/. to Path Environment variables 

Starting and Stopping ADB server:

> adb kill-server
> adb start-server

(or)

> adb server start
>adb server stop

Note: While stoping server, some times you get the following error,

cannot bind 'tcp:5037'
ADB server didn't ACK
* could not start server *

Then, go to Task manager and kill it and then you can start it again.

Note:
  In DDMS device listing not happening? 
  -> restart the adb server. That should solve your problem.
  In DDMS, device showing offline?
  -> Disconnect device from System. In device, goto Settings -> Developer  options -> disable and enable Debugging checkbox. And, reconnect it to system.

Querying for Emulator/Device Instances

 > adb devices
List of devices attached 
emulator-5554  device
emulator-5556  device
emulator-5558  device
 
Output is in "[serialNumber] [state]" format.

DIRECTING COMMANDS TO A SPECIFIC EMULATOR/DEVICE INSTANCE

If multiple emulator/device instances are running, use the -s option when issuing adb commands

> adb -s <serialNumber> <command> 

Here is an example: 
 
> adb -s emulator-5556 install helloWorld.apk

COPYING FILES TO OR FROM AN EMULATOR/DEVICE INSTANCE

To copy a file or directory (recursively) from the emulator or device, use
 
> adb pull <remote-path> <local-path>
 
To copy a file or directory (recursively) to the emulator or device, use
 
> adb push <local-path> <remote-path>

In the commands, <local-path> and <remote-path> refer to the paths to the target files/directory on your development machine (local) and on the emulator/device instance (remote).

Here's an example:
 
\>adb push foo.txt /sdcard/foo.txt
 
Note: remote path must be in Linux format
 
 

Installing an Application

> adb install <path_to_apk
  (or) 
  adb push <path_to_apk> /data/app
 
This install apk as a user dowloaded app.
 
> adb push <path_to_apk> /system/app 
 
Now, apk will be installed as System app. But, this needs target's (Mobile's) root access.
Mobile's installed with Engg binary will be having Root access.
 
If you are getting Writing access errors, use following command.

> adb remount

Logs:

To prints logs on the screen

>adb logcat

To save logs to a file

> adb logcat -f log.txt

To filter logs by log level,

> adb logcat E
This prints error logs.
Other filter options are,
  • V — Verbose (lowest priority)
  • D — Debug
  • I — Info (default priority)
  • W — Warning
  • E — Error
  • F — Fatal
  • S — Silent (highest priority, on which nothing is ever printed)
For more info,
please ref: http://developer.android.com/guide/developing/tools/adb.html

Comments