Last Updated: April 17, 2016

Things every android developer should know - part 2

Description: In the post, we'll continue the legacy of  Part 1 :-). Below are some tools provided by Google Android which is helpful for Android developers during the development and debugging session of the Production app issues

So let's get started :-)





Note: If you have missed part 1. Please refer here

1. Capture or record screen without any external app.

Often we are required to take snapshots of the app's screen or even record a video to show some features to colleagues QA or Clients. It comes in handy very often.

Step 1: Simply connect your device. Open the Android Monitor from Android Studio you'll see as fig.1.
http://code2concept.blogspot.in/
fig.1
Step 2: Now, you can open your app and click on the camera icon from the Android monitor located in the extreme top-left corner to capture any screen you want. Bingo !!!

For video: Click the video icon below the camera icon. Enter the resolution with multiples of 16x. fig.2. That's it. It'll start recording your actions on the app.

http://code2concept.blogspot.in/
fig.2



2. How to find layout boundaries?

Layout boundaries are very useful when we develop our UI components. It gives a real sense of layout, thereby letting us study the arrangement of different widgets in the layout.

Step 1: Open Settings - Developer Options - Show layout boundaries. From drawing section

https://www.linkedin.com/in/nitesh-tiwari-b5032a74
fig.3.LinkedIn app

fig.3. A Simple analysis of pencil icon. (without opening our layout)

1. The Edit pencil icon has some padding to it. 
2. It's aligned to the top-right corner of its parent layout.

Really awesome.





3. How to debug obfuscated code using proguard tool?

Note: This tool is inbuild provided by Google Android Sdk for developers and is helpful during debugging for live issues 

As we know, code is obfuscated when we build our app with Proguard enabled. We often come in contact with obfuscated code in our app while debugging the stack trace of the crashes.

So decoding is very much needed to study the stack trace. Android builds a file called "mapping.txt" which serves as the key ingredient to decode, in a combination with "retrace".

In Windows

Step 1: Go to  (android-studio-install-dir-path)\tools\proguard\bin  open "proguardgui.bat"  fig.4

fig.4
Step 2: Click on "ReTrace" fig.5. and upload your "mapping.txt" file from app/build/outputs/mapping/.../mapping.txt   and the obfuscated code file (e.g: crash.txt). You can also simply paste the stack trace in the box provided.

http://code2concept.blogspot.in/
fig.5
You can also use command line code to do that.

\tool\proguard\bin> retrace.bat -verbose   (path_to_mapping.txt)\mapping.txt  (path_to_stacktrace)\crash.txt


For more updates follow us on -  Twitter

#codingIsAnArt
#coderconsole