Gradle for Android
eBook - ePub

Gradle for Android

Kevin Pelgrims

Share book
  1. 172 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Gradle for Android

Kevin Pelgrims

Book details
Book preview
Table of contents
Citations

About This Book

If you are an experienced Android developer wanting to enhance your skills with the Gradle Android build system, then this book is for you. As a prerequisite, you will need some knowledge of the concepts of Android application development.

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is Gradle for Android an online PDF/ePUB?
Yes, you can access Gradle for Android by Kevin Pelgrims in PDF and/or ePUB format, as well as other popular books in Computer Science & Open Source Programming. We have over one million books available in our catalogue for you to explore.

Information

Year
2015
ISBN
9781783986828
Edition
1

Gradle for Android


Table of Contents

Gradle for Android
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Getting Started with Gradle and Android Studio
Android Studio
Staying up to date
Understanding Gradle basics
Projects and tasks
The build lifecycle
The build configuration file
The project structure
Creating a new project
Getting started with the Gradle Wrapper
Getting the Gradle Wrapper
Running basic build tasks
Migrating from Eclipse
Using the import wizard
Migrating manually
Keeping the old project structure
Converting to the new project structure
Migrating libraries
Summary
2. Basic Build Customization
Understanding the Gradle files
The settings file
The top-level build file
The module build file
Plugin
Android
Dependencies
Getting started with tasks
Base tasks
Android tasks
Inside Android Studio
Customizing the build
Manipulating manifest entries
Inside Android Studio
BuildConfig and resources
Project-wide settings
Project properties
Default tasks
Summary
3. Managing Dependencies
Repositories
Preconfigured repositories
Remote repositories
Local repositories
Local dependencies
File dependencies
Native libraries
Library projects
Creating and using library project modules
Using .aar files
Dependency concepts
Configurations
Semantic versioning
Dynamic versions
Inside Android Studio
Summary
4. Creating Build Variants
Build types
Creating build types
Source sets
Dependencies
Product flavors
Creating product flavors
Source sets
Multiflavor variants
Build variants
Tasks
Source sets
Resource and manifest merging
Creating build variants
Variant filters
Signing configurations
Summary
5. Managing Multimodule Builds
The anatomy of a multimodule build
The build lifecycle revisited
Module tasks
Adding modules to a project
Adding a Java library
Adding an Android library
Integrating Android Wear
Using Google App Engine
Analyzing the build file
Using the backend in an app
Custom tasks
Tips and best practices
Running module tasks from Android Studio
Speeding up multimodule builds
Module coupling
Summary
6. Running Tests
Unit tests
JUnit
Robolectric
Functional tests
Espresso
Test coverage
Jacoco
Summary
7. Creating Tasks and Plugins
Understanding Groovy
Introduction
Classes and members
Methods
Closures
Collections
Groovy in Gradle
Getting started with tasks
Defining tasks
Anatomy of a task
Using a task to simplify the release process
Hooking into the Android plugin
Automatically renaming APKs
Dynamically creating new tasks
Creating your own plugins
Creating a simple plugin
Distributing plugins
Using a custom plugin
Summary
8. Setting Up Continuous Integration
Jenkins
Setting up Jenkins
Configuring the build
TeamCity
Setting up TeamCity
Configuring the build
Travis CI
Configuring the build
Further automation
The SDK manager plugin
Running tests
Continuous deployment
Beta distribution
Summary
9. Advanced Build Customization
Reducing the APK file size
ProGuard
Shrinking resources
Automatic shrinking
Manual shrinking
Speeding up builds
Gradle properties
Android Studio
Profiling
Jack and Jill
Ignoring Lint
Using Ant from Gradle
Running Ant tasks from Gradle
Importing an entire Ant script
Properties
Advanced app deployment
Split APK
Summary
Index

Gradle for Android

Copyright © 2015 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: July 2015
Production reference: 1140715
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78398-682-8
www.packtpub.com

Credits

Author
Kevin Pelgrims
Reviewers
Peter Friese
Jonathan H. Kau
Takuya Miyamoto
Marco A. Rodriguez-Suarez
Felix Schulze
Hugo Visser
Commissioning Editor
Amarabha Banerjee
Acquisition Editor
Nikhil Karkal
Content Development Editor
Prachi Bisht
Technical Editor
Pankaj Kadam
Copy Editors
Puja Lalwani
Laxmi Subramanian
Project Coordinator
Shipra Chawhan
Proofreader
Safis Editing
Indexer
Tejal Soni
Production Coordinator
Manu Joseph
Cover Work
Manu Joseph

About the Author

Kevin Pelgrims started his career as a .NET developer in Belgium. After some years working on Windows and web development for corporate clients, he moved to Copenhagen to become part of its start-up community. There, he began working on mobile platforms, and within a year, he was the lead developer of several Android and Windows Phone apps. Kevin is also a regular speaker at the Android developers group in Copenhagen. He maintains multiple Android apps in his spare time and likes to experiment with server-side technology. When he is not busy writing code, he is most likely playing the guitar with his wife and their cat.
To follow what Kevin is up to, you can take a look at his blog at http://www.kevinpelgrims.com or follow him on Twitter at @kevinpelgrims.

Table of contents