Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Mastering Android Development with Kotlin

You're reading from   Mastering Android Development with Kotlin Deep dive into the world of Android to create robust applications with Kotlin

Arrow left icon
Product type Paperback
Published in Nov 2017
Publisher Packt
ISBN-13 9781788473699
Length 378 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Miloš Vasić Miloš Vasić
Author Profile Icon Miloš Vasić
Miloš Vasić
Arrow right icon
View More author details
Toc

Table of Contents (17) Chapters Close

Preface 1. Starting with Android 2. Building and Running FREE CHAPTER 3. Screens 4. Connecting Screen Flow 5. Look and Feel 6. Permissions 7. Working with Databases 8. Android Preferences 9. Concurrency in Android 10. Android Services 11. Messaging 12. Backend and API 13. Tuning Up for High Performance 14. Testing 15. Migration to Kotlin 16. Deploying Your Application

Other important tools

We will cover some other tools you will need in everyday Android development.

Let's start with the following:

  • adb dumpsys: To get information about a system and running an application, use the adb dumpsys command. To get a memory status, execute the following command--adb shell dumpsys meminfo <package.name>.

Next important tool is as follows:

  • adb shell procrank: The adb shell procrank lists all the applications for you in the order of their memory consumption. This command does not work on live devices; you connect only with emulators. For the same purpose, you can use--adb shell dumpsys meminfo.
  • For battery consumption, you can use--adb shell dumpsys batterystats--charged <package-name>.
  • Next important tool is Systrace. To analyze performance of your application by capturing and displaying execution times, you will use this command.

When you have problems with application glitches, Systrace tool comes as a powerful ally!

It does not work with Android SDK Tools less than 20! To use it, you must have Python installed and configured.

Let's try it!

To access it from UI, open Android Device Monitor in Android Studio and then choose Monitor:

Sometimes, it can be easier to access it from the terminal (command line):

The Systrace tool has different command-line options, depending on the Android version running on your device.

Let's take a look at some examples:

General usage:

$ python systrace.py [options] [category1] [category2] ... [categoryN]
  • Android 4.3 and up:
        $ python systrace.py --time=15 -o my_trace_001.html 
sched gfx view wm
  • Android 4.2 and lower options:
        $ python systrace.py --set-tags gfx,view,wm
        $ adb shell stop
        $ adb shell start
        $ python systrace.py --disk --time=15 -o my_trace_001.html

The last important tool we want to present is sdkmanager. It allows you to view, install, update, and uninstall packages for the Android SDK. It is located in android_sdk/tools/bin/.

Let's take a look at some common examples of use:

Listing installed and available packages:

sdkmanager --list [options]
  • Installing packages:
        sdkmanager packages [options]

You can send packages you got from --list command.

  • Uninstalling:
        sdkmanager --uninstall packages [options]
  • Updating:
        sdkmanager --update [options]

There are also some other tools you can use in Android, but we only showed the most important ones.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image