1

Android debugging : What is a break point and how to watch variables while debugging android program?

  • break point breaks the execution. Put cursor on variables to see the value
  • break points are hit when crash happens. Put cursor on variables to see the values
  • break point breaks the execution. To see value either you can put cursor on it or right click on variables and add to watch
  • break point are hit when crash happens. To see value either you can put cursor on it or right click on variables and add to watch

Answer: C break point breaks the execution. To see value either you can put cursor on it or right click on variables and add to watch
Description: Debugging : means removing the bug (issue).
There can be two types of bugs.
1. Program crash : When program crashes due to some exception, then we have to debug the program through logcat and find the problem. These kind of debugging will be done through logcat messages.
2. Function is not working properly : If some logic is not working properly, then we have to analyze that function to see what logic is going wrong. This can be done in many ways.
a. Put toast messages in the function to see line by line analysis
b. Put log messages by using Log.d OR other log functions, and see for those messages in logcat.
c. Put break point by double clicking a particular line in eclipse. Break point is a point where control will stop at that line while executing. Once it hits that point, it will break/ halt the execution. There you can explore all the variable values by adding variables to watch windows.

2

What is DDMS in android?

  • dalvik debug monitor server
  • dalvik debug monitoring service
  • dalvik daemon machine server
  • dalvik daemon machine service

Answer: A dalvik debug monitor server
Description:

3

What is log.d ? where to use log functions?

  • deamon log
  • debug log
  • dalvik log
  • ddms log

Answer: B debug log
Description: Log messages are used to debug the program.

Log.d() is debug log.

other functions are Log.i() - informative
Log.e() - error log
Log.w() - warning log
Log.v() - verbose log

4

What is ADB?

  • It is a client-server modeled tool that is used as bridge between client in host machine & adb daemon in emulator or device.
  • Option1 is true & This tool is located in android-sdk/platform-tools folder
  • Option1 is true & This tool is located in android-sdk/tools folder
  • none of the above are true

Answer: B Option1 is true & This tool is located in android-sdk/platform-tools folder
Description: ADB is a client-server modeled tool available in android-sdk/platform-tools, that is used as bridge (communication channel) between client in host machine & adb daemon in emulator or device. ADB has 3 components in it client, server, and adb daemon.
In simple terms, it is a communication channel between eclipse and emulator/ device

5

When a new emulator is created,how many ports will be allocated to it?

  • 2
  • 1
  • 4
  • 0

Answer: A 2
Description: For every emulator or device connected to server, it will be allocated with 2 ports (starting from 5554 & 5555) based on the port availability.

6

What are the uses of DDMS (Dalvik Debug Monitor Server) tool in android?

  • i.Used to simulate calls & SMSs.
  • ii. we can see thread allocation & memory allocation of any process running in phone or emulator.
  • iii. we can see logs in logcat tool which is part of DDMS. Used for debugging the program.
  • iv. we can simulate GPS locations also using DDMS tool.
  • i
  • i & ii
  • i, ii, & iii
  • i, ii, iii, & iv

Answer: D i, ii, iii, & iv
Description: Using DDMS tool we can

i.Simulate calls & SMSs.
ii. We can see thread allocation & memory allocation of any process running in phone or emulator.
iii. We can see logs in logcat tool which is part of DDMS. Used for debugging the program.
iv. We can simulate GPS locations also using DDMS tool.

7

what does adb devices command will do in android?

  • i. it resets all the devices connected to ADB server.
  • ii. it will display all the devices connected to the ADB server.
  • iii. it displays only online devices.
  • iv. it displays online & offline devices as well.
  • i
  • ii
  • i & iii
  • ii & iv

Answer: D ii & iv
Description: adb devices --> this command will display all the offline and online devices attached to the adb server.

8

What is adb ?

  • Android Debug Bridge - can be used to access android tools from command line interface.
  • Android Direct Bridge - can be used to start emulator.
  • Android Direct Bridge - provide acces to databases on the rooted device.
  • None are correct.

Answer: A Android Debug Bridge - can be used to access android tools from command line interface.

Description: Android debug bridge (ADB)
- tool used to communicate to emulator/ devices from eclipse or command prompt.
- its a client-server program

there are 3 components in it:
1. a client running on development machine. -> you can invoke this by issueing adb shell command.
(adt/ ddms also starts adb client)

2. a server [runs as a b.g process] on development machine.
this establishes comm'on channel between client - adb daemon running on emulator/ device.

3. adb-daemon that runs on emulator/ device.
adb -> is located in sdk/ platform-tools

9

How to install an APK file into emulator 5556. Assume that ADB server might be connected to more than one emulator at that time.

  • adb -s emulator-5556 install helloWorld.apk
  • adb install -s emulator-5556 helloWorld.apk
  • adb install helloWorld.apk
  • adb -s install emulator-5556 helloWorld.apk

Answer: A adb -s emulator-5556 install helloWorld.apk
Description:

10

What is the maximum & minimum port numbers for emulators or devices?

  • 5554&5555 is minimum. 5584&5585 is maximum.
  • 5034&5035 is minimum. 5084&5085 is maximum.
  • 5034&5035 is minimum. 5064&5065 is maximum.
  • 5554 is minimum & 5585 is maximum.

Answer: A 5554&5555 is minimum. 5584&5585 is maximum.
Description:

11

What is adb? What is the command to install one application using adb command prompt?

  • its a client server program to communicate between development machine, and emulator.
  • its a client server program to communicate between development machine, and device.
  • its a client server program to communicate between development machine, and device or emulator.
  • its a client server program to communicate between eclipse in development machine, and eclipse.

Answer: C its a client server program to communicate between development machine, and device or emulator.
Description: Android debug bridge (ADB)
- tool used to communicate to emulator/ devices from eclipse or command prompt.
- its a client-server program

there are 3 components in it:
1. a client running on development machine. -> you can invoke this by issueing adb shell command.
(adt/ ddms also starts adb client)

2. a server [runs as a b.g process] on development machine.
this establishes comm'on channel between client - adb daemon running on emulator/ device.

3. adb-daemon that runs on emulator/ device.
adb -> is located in sdk/ platform-tools

How is this connection established?
1. once you issue adb command, it starts adb client,
then searches if server process if exists or not.

2. once server started, it will start listening --> on port 5037 --> for commands from [adb client]
It will start connections from client - to - adb daemons.

how server detects adb-daemons?
a. server will check ports 5555 -to- 5585
if it finds any port then it will set up connection.

Note: consoles will take up even ports, adb daemons will take up odd ports.

eg: Emulator 1, console: 5554
Emulator 1, adb: 5555
Emulator 2, console: 5556
Emulator 2, adb: 5557 ...

it is multi connection (Means any client can talk to any daemon)

Commands:
adb [-d ] ==> to issue command to a device/emulator
adb devices
adb -s emulator-5556 install helloWorld.apk
adb install

command to install an apk into emulator is:
adb install

command to install an apk to particular emulator 5556 is:
adb -s emulator-5556 install helloWorld.apk

12

What are the debugging techniques available in android?

  • use DDMS log cat to see the log flow and to analyze the crash
  • use break points to see the flow
  • use memory profiling to analyze memory
  • all of the above

Answer: D all of the above
Description: Based on the requirement one can use any of the above techniques. use logcat to see the control flow or to analyze the crash. use break point if you want to clearly watch the stack trace and variable values at run time. use memory profiling and thread profiling if you want to see how much memory and how many thread are created at run time.

13

How to analyze android application crash, how to fix crash using logcat?

  • I will put a break point in logcat and analyze it.
  • after crash logcat will contain exception name along with line number where it has crashed.
  • I will put a break point in code and analyze.
  • after crash logcat will contain filename where it has crashed, and also it has variable values also.

Answer: B after crash logcat will contain exception name along with line number where it has crashed.
Description: after crash logcat will contain exception name along with line number where it has crashed.

14

What is the port number, that ADB server listens at, to get commands from adb clients?

  • 5035
  • 5554
  • 5555
  • 5037

Answer: D 5037
Description: 5037. Every ADB client can communicate to server on port number 5037.