Table of Contents
Foreword vii
Preface ix
1 Gradle for Android Basics 1
1.1 Gradle Build Files in Android 1
1.2 Configure SDK Versions and Other Defaults 6
1.3 Executing Gradle Builds from the Command Line 9
1.4 Executing Gradle Buiids from Android Studio 15
1.5 Adding Java Library Dependencies 18
1.6 Adding Library Dependencies Using Android Studio 23
1.7 Configuring Repositories 26
2 From Project Import to Release 29
2.1 Setting Project Properties 29
2.2 Porting Apps from Eclipse ADT to Android Studio 33
2.3 Porting Apps from Eclipse ADT Using Eclipse 37
2.4 Upgrading to a Newer Version of Gradle 40
2.5 Sharing Settings Among Projects 43
2.6 Signing a Release APK 45
2.7 Signing a Release APK Using Android Studio 49
3 Build Types and Flavors 53
3.1 Working with Build Types 53
3.2 Product Flavors and Variants 56
3.3 Merging Resources 60
3.4 Flavor Dimensions 67
3.5 Merging Java Sources Across Flavors 71
4 Custom Tasks 77
4.1 Writing Your Own Custom Tasks 77
4.2 Adding Custom Tasks to the Build Process 80
4.3 Excluding Tasks 83
4.4 Custom Source Sets 85
4.5 Using Android Libraries 88
5 Testing 97
5.1 Unit Testing 97
5.2 Testing with the Android Testing Support Library 103
5.3 Functional Testing with Robotium 108
5.4 Activity Testing with Espresso 112
6 Performance and Documentation 119
6.1 Performance Recommendations 119
6.2 DSL Documentation 125
A Just Enough Groovy to Get By 129
B Gradle Basics 139
Index 147