Tuesday, 27 December 2016




Open terminal in android studio

type below sequencially in terminal

1. adb shell

2.adb version

3. RESULT : Android Debug Bridge version 1.0.31


FULL                                                                                    .


shell@htc_v02_dug:/ $ adb version
Android Debug Bridge version 1.0.31


//

Android Phone Product and Model


Open terminal in android studio

type below sequencially in terminal

1. adb shell

2. getprop ro.product.model

3. RESULT : HTC Desire 526GPLUS dual sim

Unistalling App with Terminal



1. To uninstall apk
Open Terminal in android studio  --> type ' adb uninstall package_name'

like - adb uninstall com.example.cybermatrix3.testone

2. After that, you will see succesfull message and check your phone

Installing App with Terminal

A. Installing New Apk

Syntax :
 adb install <path of Apk>
 adb install -d <path of Apk>

1. Open Terminal ---> Type ' adb install <path of Apk' like - adb install D:\TestOne.apk

--- > Install successfull

Note : a - It does not automatically launch app, so you need to open app
b - If more than one devices connected with android studio then it does not install apk

B. Reinstalling Apk
If the app already exists on the device, you may need to use the -r option in order to reinstall it


1. Open Terminal ---> Type ' adb install -r <path of Apk' like - adb install -r D:\TestOne.apk

--- > Install successfull

Note : a - It does not automatically launch app, so you need to open app
b - If more than one devices connected with android studio then it does not install apk

SOME MORE HELPING COMMAND LIKE -r

******************************************************

 -l: install the package with FORWARD_LOCK.
    -r: reinstall an exisiting app, keeping its data.
    -t: allow test .apks to be installed.
    -i: specify the installer package name.
    -s: install package on sdcard.
    -f: install package on internal flash.
    -d: allow version code downgrade.
******************************************************

Connect Device Over WIFI

Connect to a device over Wi-Fi


adb is usually used over USB. However, it is also possible to use over Wi-Fi, as described here.
  1. Connect your Android device and adb host computer to a common Wi-Fi network accessible to both. Beware that not all access points are suitable; you may need to use an access point whose firewall is configured properly to support adb.
    Note: If you are attempting to connect to an Android Wear device, force it to connect to Wi-Fi by shutting off Bluetooth on the phone connected to it.
  2. Connect the device to the host computer with a USB cable.
  3. Set the target device to listen for a TCP/IP connection on port 5555.
    $ adb tcpip 5555
    
  4. Disconnect the USB cable from the target device.
  5. Find the IP address of the Android device. For example, on a Nexus device, you can find the IP address at Settings > About tablet (or About phone) > Status > IP address. Or, on an Android Wear device, you can find the IP address at Settings > Wi-Fi Settings > Advanced > IP address.
  6. Connect to the device, identifying it by IP address.
    $ adb connect device_ip_address
    
  7. Confirm that your host computer is connected to the target device:
    $ adb devices
    List of devices attached
    device_ip_address:5555 device
    
You're now good to go!
If the adb connection is ever lost:
  1. Make sure that your host is still connected to the same Wi-Fi network your Android device is.
  2. Reconnect by executing the adb connect step again.
  3. Or if that doesn't work, reset your adb host:
    adb kill-server
    
    Then start over from the beginning.

Connect Android Phone with Android Studio

Connect with IP Address of Device
adb connect <host>[:<port>]

1. Get IP Address
Setting --->  about Phone ---> Status --->  IP Address

2. Go Terminal in Android Studio --->
a.  type ' adb connect ip-address '  like - adb connect 192.168.1.9
or
b. type ' adb connect ip-address:port '  like - adb connect 192.168.1.9:5555

RESULT :  connected to 192.168.1.9:5555

***************Full Example

D:\PROJECT\Project - Backup\Philips\PdfReader1>adb connect 192.168.1.9
connected to 192.168.1.9:5555



Show All devices

Show All devices connected with system


1. Open Terminal in Android Studio
2. Type ' adb devices '
3 It's show all devices connected with Android Studio with serial number
like this -

D:\PROJECT\Project - Backup\Philips\PdfReader1>adb devices
List of devices attached
adb server version (31) doesn't match this client (36); killing...
* daemon started successfully *
GDF91YL00618    device



Note - Check serial number in Android Phone

Setting ---> About Phone ---> Status ---> You will see 'Serial Number '


.

Android Terminal and adb Configuration




A. Set path of adb ( Android Debugging Bridge )

1.  find your sdk
Note - Go to File tab -->  Project Structure --> Android SDK Location.
2. Choose Platform Tools

YOUR_SDK_LOCATION\SDK\PLATFORM-TOOLS

In my case : C:\Users\Divakar\AppData\Local\Android\Sdk\platform-tools

Copy it
3. Now go to property of  your computer

Window 10 - this pc ---> right click ----> property
other window pc : my computer ---> right click ----> property

After that property

Advance System Setting ---> Advance tab ---> Environment variable --->
Two Option
a. User variable --- Setting applicable on current user in System
b. System Variable --- Setting applicable on all user in System

---> path  --> paste the platforms-tools path (C:\Users\Divakar\AppData\Local\Android\Sdk\platform-tools )  ---> ok --->  ok ---> Close

4. Now goto android studio ---> Click on 'Terminal' on bottom bar ---> type ' adb -help'  ---> Enter

Oooohhhooooooooo..........  it's working