High Performance Android Apps
by Doug Sillars
Copyright 2015 AT&T Services, Inc. All rights reserved.
Printed in the United States of America.
Published by OReilly Media, Inc. , 1005 Gravenstein Highway North, Sebastopol, CA 95472.
OReilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://safaribooksonline.com). For more information, contact our corporate/institutional sales department: 800-998-9938 or corporate@oreilly.com .
- Editors: Brian Anderson and Courtney Allen
- Production Editor: Shiny Kalapurakkel
- Copyeditor: Jasmine Kwityn
- Proofreader: Elise Morrison
- Indexer: Judy McConville
- Interior Designer: David Futato
- Cover Designer: Karen Montgomery
- Illustrator: Rebecca Demarest
- September 2015: First Edition
Revision History for the First Edition
- 2015-09-04: First Release
See http://oreilly.com/catalog/errata.csp?isbn=9781491912515 for release details.
The OReilly logo is a registered trademark of OReilly Media, Inc. High Performance Android Apps, the cover image, and related trade dress are trademarks of OReilly Media, Inc.
While the publisher and the author have used good faith efforts to ensure that the information and instructions contained in this work are accurate, the publisher and the author disclaim all responsibility for errors or omissions, including without limitation responsibility for damages resulting from the use of or reliance on this work. Use of the information and instructions contained in this work is at your own risk. If any code samples or other technology this work contains or describes is subject to open source licenses or the intellectual property rights of others, it is your responsibility to ensure that your use thereof complies with such licenses and/or rights.
978-1-491-91251-5
[LSI]
Foreword
For the majority of Android Developers out there, the concept of
performance is the last thing on their minds. Most app development is a mad sprint towards getting features in, making the UI look perfect, and figuring out a viable monetization strategy. But, application performance is a lot like the plumbing in your house; When its working great, no one notices, or thinks about it... but when somethings wrong, suddenly everyone is in trouble.
You see, users notice bad performance before any of the other features in your app. Before your social widgets, awesome image filters, or how one of your supported languages is Klingon. And guess what, users unhappy with performance, give bad reviews at a higher percentage than any other problems in your app.
This is why we say that #PERFMATTERS. Its easy to lose sight of performance as youre developing your app, but frankly, its involved with everything you do; when users feel bad performance, they complain about bad performance, they uninstall your app, and then vengefully give you a bad review! When you think of it this way, performance sounds more like a feature that you should focus on, rather than a burden you have to put up with.
But in all honesty, improving performance is a really tough thing to do. Its not enough to understand your algorithm, you need to understand how Android is responding to it, and then how the hardware is responding to Android. The truth is, that one line of code can trash the performance of your entire app, simply because its abusing some hardware limitation. But you cant stop there, because in order to even understand whats going on under the hood, you have to learn a whole separate set of tools that are built just for performance profiling. Basically, its an entirely new way of looking at application development, and its not for the faint of heart.
But thats whats so great about the book that Doug has put together here. Its the in the trenches guide to everything performance on Android. Not only does it cover the basic algorithm topics, but also goes into how the hardware and platform are working so you can understand what the crazy tools are telling you. This is the type of book that helps to transform an engineers perspective of the platform. It stops being about views and event listeners, and slowly grows to an understanding of memory boundaries and threading problems.
When its 4am , your app is running poorly, the coffee machine is out, and your startup incubator room smells like cabbage; this is the book youll crack open to make sure that 10:00 AM meeting with the Venture Capitalists runs smoothly.
Good luck!
Colt McAnlis, Senior Staff Developer Advocate, Google Inc.Team Lead, Android Performance Patterns - https://goo.gl/4ZJkY1
Preface
You are building an Android application (or you already have). Despite this, you are not totally happy with your apps performance (why else did you pick up this book?). Uncovering mobile performance issues is a job that is never complete. In my research, I found that 98% of apps tested had room for potential performance improvements. This book will cover the pitfalls of mobile performance and introduce you to some of the tools to test for issues. My goal is to help you acquire the skills necessary for catching any major performance issues in your mobile app before they impact your customers.
Studies have shown that customers expect mobile apps to load quickly, rapidly respond to user interactions, and be smooth and pleasing to the eye. As apps get faster, user engagement and revenue increase. Mobile apps built without an eye on performance are uninstalled at the same rate as those that crash. Apps that inefficiently use resources cause unnecessary battery drain. The number one complaint carriers and device manufacturers hear from customers concerns battery life.
I have spoken to thousands of developers about Android app performance over the last few years, and few developers were aware of the tools available for solving the issues they experience.
The consensus is clear: mobile apps that are fast and run smoothly are used more often and make more money for developers. With that information, it is surprising that more developers are not using the tools that are available to diagnose and pinpoint performance issues in their apps. By focusing on how performance improvements affect the user experience, you can quickly identify the return on investment that your performance work has made on your mobile app.
Who Should Read This Book
This book covers a wide range of topics centering around Android performance. Anyone associated with mobile development will appreciate the research around app performance. Developers of non-Android mobile apps will find the arguments and issues around app performance useful, but the tools used to isolate the issues are Android specific.
Testers will find the tutorials of tools used to test Android performance useful as well.
Why I Wrote This Book
There is a large and burgeoning field of web performance in which developers share tips on how to make the Web fast. Steve Souders wrote High Performance Web Sites in 2007 (OReilly), and the topic is covered in books, blogs, and conferences.
Until recently, there has been very little focus on mobile app performance. Slow apps were blamed on the OS or the cellular network. Poor battery life was blamed on device hardware. As phones have gotten faster and the OSs have matured, customers are realizing that mobile apps have a role in the performance of their phones.
There are many great tools for measuring Android app performance, but until now, there hasnt been a guide listing them all in one place. By bringing in tools from Google, Qualcomm, AT&T, and others, I hope this book will take some of the mystery out of Android performance testing, and help your app get faster while not killing your customers batteries.