Gradle & Android Studio - Introduction

2,926 views

Published on

This is a very high level overview of Gradle. Android Studio tips and tricks were shown during demos, so the slides themselves don't really contain any info on Android Studio.

Published in: Technology
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
2,926
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
83
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Gradle & Android Studio - Introduction

  1. 1. Gradle & Android Studio An introduction
  2. 2. drivr.com @drivr FIRSTDRIVR
  3. 3. Schedule ● ● ● ● ● ● Why Gradle? Converting an existing project Build types and product flavors Custom tasks Testing Continuous integration
  4. 4. Why Gradle?
  5. 5. Pros ● Not Ant ● Groovy-based ● Gradle wrapper ● Multi-project builds ● Dependency management
  6. 6. Cons ● Slower than Ant ● Documentation ● Android plugin under development ● Dependency management
  7. 7. Demo - New project
  8. 8. Convert a project
  9. 9. How to convert ● Project structure ● Gradle wrapper ● Dependencies Good resource: http://ryanharter.com/blog/2013/07/17/migrating-android-projects-to-gradle
  10. 10. Types & flavors
  11. 11. Build types ● E.g. debug, staging, production ● Separate packages ● Different resources
  12. 12. Build types - Example buildTypes { staging { packageNameSuffix ".staging" versionNameSuffix "-staging" signingConfig signingConfigs.staging } }
  13. 13. Build types - Example signingConfigs { staging { storeFile file("staging.keystore") storePassword "storepwd" keyAlias "alias" keyPassword "keypwd" } }
  14. 14. Build types - Example module src staging java res AndroidManifest.xml
  15. 15. Product flavors ● E.g. free, pro ● Multi APK (e.g. <= 2.2 & > 2.2) ● Combination Setup: same as build types
  16. 16. Build variants Build type + Product flavor = Build variant ● Pro Debug & Free Debug ● Pro Staging & Free Staging ● ...
  17. 17. Custom tasks
  18. 18. Custom tasks - Example task keyStorePassword << { def keystorePw = new String( System.console().readPassword ("Password?")) android.signingConfigs.release .storePassword = keystorePw }
  19. 19. Custom tasks - Example tasks.whenTaskAdded { task -> if (task.name.equals("packageRelease")) { task.dependsOn "keyStorePassword" } }
  20. 20. Testing
  21. 21. Instrumentation tests ● No separate project ○ srcinstrumentTest ● Own dependencies ○ dependencies { instrumentTestCompile x } ● gradlew connectedInstrumentTest
  22. 22. Unit tests (JUnit & Robolectric) ● No official support ● Add custom task ● Some hacking required
  23. 23. Continuous integration
  24. 24. CI with Jenkins ● Android SDK on build server ● Gradle plugin - “Invoke Gradle script” ● Emulator support Good resource: http://blog.zuehlke.com/configure-your-android-project-on-jenkins/
  25. 25. Want to get started?
  26. 26. Resources http://tools.android.com/tech-docs/new-build-system/user-guide http://www.gradle.org/documentation https://plus.google.com/+AndroidDevelopers/posts https://gradleplease.appspot.com DuckDuckGo / Google
  27. 27. Contact me @kevinpelgrims http://kevinpelgrims.com/blog

×