Cover image for Android Developer Tools Essentials

Book description

Developing Android apps is a challenge: it's hard enough to write high-performing apps that run well, but you've also got to make them look good on a wide variety of Android devices. This book will guide you through the proper usage of all of these tools by describing in detail what each tool is designed to do, when and how to use them, and how to integrate them into your development workflow.

Table of Contents

  1. Special Upgrade Offer
  2. Preface
    1. Requirements for Android Developer Tools
    2. Development Process for Android Developer Tools
    3. Development on a Variety of OS Platforms
    4. Conventions Used in This Book
    5. Using Code Examples
    6. Safari® Books Online
    7. How to Contact Us
    8. Acknowledgments
  3. 1. Getting Started
    1. Minimum Requirements
    2. Installing Java
    3. Installing the Android Software Development Kit
      1. Installing the ADT Bundle
        1. Downloading the ADT bundle
        2. Extracting the tools to Android Home
        3. Unzip the downloaded artifact to the Android folder
        4. Setting your PATH variable
        5. Validating the installation
    4. Developing Without Eclipse
      1. Command-Line Usage
      2. Using a Different IDE
    5. Configuring a Device for Development
  4. 2. Essential Tools
    1. SDK Manager
      1. SDK Components
      2. Starting the SDK Manager
      3. Viewing Installed and Available Components
        1. Selecting packages
        2. Installing packages
        3. Deleting and updating components
        4. Managing dependencies
      4. ADT Preview Channel
        1. Enable the Preview Channel
        2. Installing Preview Tools
        3. Reverting to released tools
    2. Android Debug Bridge (ADB)
      1. Starting ADB
      2. Querying for Device Instances
        1. Find connected devices
        2. Directing a command to a specific device
      3. Issuing Commands
        1. Transferring files
        2. Managing applications on a device
      4. The Shell Command
        1. Interactive mode
        2. One-off mode
        3. Retrieving system data
        4. Using the Activity Manager
      5. ADB Does a Lot More
      6. Resetting the ADB Server
      7. Additional Resources
  5. 3. Configuring Devices and Emulators
    1. Using a Physical Device for Development
      1. Capabilities and Limitations
        1. Capabilities
        2. Limitations
      2. Configuring a Physical Device for Development
    2. Using an Emulator for Development
      1. Supported Features
        1. Supported features
        2. Unsupported features
    3. Android Virtual Devices
      1. Creating AVDs
        1. AVD Manager
        2. Creating AVDs from the command line
        3. Location of the AVD files
      2. Emulator Options
    4. Advanced Emulator Configuration
      1. Using Hardware Acceleration
        1. Benefits
        2. Limitations
        3. Downloading the components
        4. Installing the HAXM software
        5. Configuring an AVD
        6. Validating that HAXM is running
      2. Disabling the Boot Animation
      3. On Windows: Dedicating a Core to the Emulator
  6. 4. Using Devices and Emulators
    1. Using the Emulator
      1. Starting the Emulator
        1. AVD launch options
        2. Starting an emulator from the command line
        3. Using snapshots to improve performance
        4. Saving and retrieving a snapshot
      2. The Emulator Application
      3. The Devices Tool
      4. Keyboard Shortcuts
    2. File Explorer
    3. Developer Tools Application
  7. 5. Developing with Eclipse
    1. Anatomy of the Eclipse Workspace
      1. Uncovering Additional Tools and Views
      2. Quick Button
    2. Code Templates
    3. Properties Editors
    4. XML Formatter
    5. The Android Key
    6. Quick Outline for XML
    7. Other Essential Eclipse Shortcuts
    8. Refactor Menu
  8. 6. Developing with Android Studio
    1. Installing Android Studio
      1. Bundled SDK
      2. Default Project Location
    2. Anatomy of the Android Studio IDE
      1. Panels
      2. Toolbars
      3. Useful Actions in Android Studio
      4. Navigation
    3. The New Structure of an Android Project
      1. A Tour Around the New Structure
      2. Running and Debugging an Android Project
    4. Creating New Android Components
    5. Layout Designer and Layout Preview
      1. Layout Designer
      2. Layout Preview
    6. Generating an APK
    7. Interacting with Maven and Gradle
      1. Interacting with Maven
      2. Interacting with Gradle
    8. Version Control Integration
    9. Migrating from Eclipse
    10. Android Studio Tips and Tricks
      1. Refactoring and Code Generation
      2. Miscellaneous Shortcuts
  9. 7. Testing Your Code
    1. Logcat
      1. Viewing the Logcat File
      2. Anatomy of a Log Message
        1. Reading logcat output
      3. Filtering Based on Logging Level
      4. Using Tags to Filter Output
      5. Getting the Most Out of Logcat
      6. Viewing Alternative Log Buffers
      7. Predefined Output Formats
      8. Logcat Viewer in Eclipse
      9. Logcat Example
        1. Determining areas to monitor
        2. Creating log statements
        3. Verbose logging
        4. Filtering the logcat
    2. Debugging
      1. Setting Your App to Debuggable
      2. Setting a Debug Point
      3. The Eclipse Debug Perspective
      4. Debugging Example
        1. Setting the debug points
        2. Starting the debugger
        3. Stepping through the code
    3. Lint
      1. Command-Line Usage
        1. Excluding issues
      2. Running in Eclipse
        1. Lint toolbar menu
        2. Java and XML editor integration
        3. Quick Fix tool
  10. 8. Simulating Events
    1. Simulating Location and Routes
    2. Simulating Telephony Operations
    3. Changing Networking Parameters
    4. Using a Device with Sensor Emulation
    5. Advanced Sensor Testing
      1. Supported Sensors
      2. Simulating Sensor Events in Real Time
      3. Recording Sensor Scenarios
    6. Developer Options Menu
  11. 9. Build Tools
    1. Compiling Your Code
    2. Packaging an APK for Release
      1. Signing Your App
    3. Building from the Command Line Using Ant
      1. Setting Up Your Project
        1. Creating the Ant build.xml file
        2. Building applications from multiple source libraries
      2. Building in Debug Mode
      3. Building an App to Release to the Play Store
        1. Signing an app with a custom keystore
        2. Storing the password information
      4. Additional Ant Commands
    4. Advanced Packaging Steps
      1. ProGuard
        1. Enabling Proguard
        2. Configuring ProGuard
        3. Viewing obfuscated code
      2. Zipalign
    5. Gradle-Based Build Tools
      1. Installing Gradle
      2. Creating Multiple Build Variations
        1. Example
      3. Build File
      4. Build Tasks
      5. Generating a Gradle Build from Eclipse
    6. Using the Maven Tools
  12. 10. Monitoring System Resources
    1. Memory Usage in Android
    2. Dalvik Debug Monitor Server (DDMS)
      1. Launching the DDMS Perspective
      2. Analyzer Tool
        1. Running the tool
        2. Viewing the results of Analyzer Tool
      3. Threads
        1. Running the Threads tool
        2. Viewing thread information
      4. Heap
        1. Running the Heap tool
        2. Viewing heap information
      5. Traceview
        1. Traceview output—timeline panel (top section)
        2. Profile panel
    3. Memory Analyzer Tool (MAT)
      1. Generating an HPROF File
      2. HPROF File
      3. Installing MAT into Eclipse
      4. Launching MAT from Within Eclipse
      5. Using MAT to Analyze HRPOF Files
      6. The MAT Overview Screen
      7. Viewing a Report
  13. 11. Working with the User Interface
    1. Android Layout Basic Concepts
      1. Defining Layouts Using XML
      2. Views and ViewGroups
      3. Resources
      4. Leveraging ADT to Build Great UIs
    2. Editing XML Files Directly
      1. Using Templates
      2. Editing XML Directly
        1. Code completion
        2. Inserting new layouts or widgets
        3. Attribute values
        4. Refactor menu
        5. XML formatting
        6. Editor Preferences menu
    3. Working with Graphics
      1. The Asset Tool
      2. Using Nine-Patch Images
      3. Asset Studio Website
  14. 12. Using the Graphical Editor
    1. Generating Layouts Using the Graphical Layout Editor
    2. Palette
    3. Canvas
      1. Layout Actions
      2. Context-Sensitive Menu
    4. Outline View
    5. Properties Editor
    6. Configuration Chooser
  15. 13. Optimizing the User Interface
    1. Introduction to UI Performance
      1. How Android Draws Views, and How It Affects UI Performance
        1. Two-pass layout
        2. Nested layouts reduce performance
    2. Hierarchy Viewer
      1. Starting the Hierarchy Viewer
      2. Loading the View Hierarchy into the Tools
      3. Navigating the Tree Hierarchy
      4. Gathering View Information
        1. Measurement information
        2. Identification and performance indicators
      5. Gathering View Rendering Details
      6. Example: Debugging a UI Using the Hierarchy Viewer
        1. Different ways to design a UI
        2. Using the Tree View to get timing information
        3. Reviewing the structure with the Tree Overview
        4. Using the Tree tool to inspect the bad UI
        5. Using the Tree tool to inspect the good UI
    3. Fixing Problems Using Lint
    4. Application Exerciser Monkey
      1. Grooming the Monkey
        1. Letting the Monkey free
        2. Specifying event types and frequency
        3. Verbosity level
        4. Setting a seed value
    5. Monkeyrunner
      1. Using Python to Create the Script
    6. Thanks for Reading!
  16. Index
  17. About the Author
  18. Colophon
  19. Special Upgrade Offer
  20. Copyright