View
176
Download
2
Category
Preview:
Citation preview
Froyo to KitKatTwo Years Developing & Maintaining DeliRadio
by Andy Dyer
About Me
• Android & Rails developer at ChaiOne in Houston, Texas, USA
• Android apps on Google Play - DeliRadio, Music Library, and Wrist Presenter
• Hobbies/Interests - Vinyl collector, coffee & beer snob, burger aficionado
• Ich lerne Deutsch
About DeliRadio
• Explore local concert calendars
• Stream stations based on location or specific venues
• Share discoveries with friends
• Receive notifications when favorite artists play nearby
About DeliRadio - Navigation & Filters
About DeliRadio - Server Architecture
• Sinatra/Ruby API used by Android, iOS, and third-party clients
• Virtual private cloud
• Web, database, and job servers
• Hosted on Amazon S3 & CloudFront CDN
• ElasticSearch & Redis for caching & high performance search
Supported Android Versions Over Time
Early 2012
Min: Froyo Max: Honeycomb
Mid 2012
Min: Froyo Max: ICS
Early 2013
Min: Gingerbread Max: Jelly Bean
Early 2014
Min: ICS Max: KitKat
Topics
• Development Tools & Build Process
• Libraries Used
• Graphics & User Interface
• QA & Testing
Topics
• Development Tools & Build Process
• Libraries Used
• Graphics & User Interface
• QA & Testing
Development Tools (Early to Mid 2012)
Eclipse
• But which one?
• Build System: Ant
• Dependencies: JAR files or Maven (if you’re patient)
Development Tools (Mid 2012 to Mid 2013)
Android Developer Tools (ADT) Bundle
• Android specific version of Eclipse
• Slightly more lightweight
Build Process - Eclipse & ADT
• Initial approach - File > Export, manually enter keystore password, etc.
• Slightly better approach - Template based Ant build
• Release & debug resources
• Custom Ant build targets with config specific tokens
• Templates for manifest and other source files
Build Process - Eclipse & ADT
Problems with this approach
• Non-standard
• Templates must be be updated instead of main files (i.e. manifest gets overwritten with populated template on each build)
• Switching between release & debug must be done via the command line. IDE just builds current files.
Development Tools (Mid 2013 to Present)
Android Studio
• Gradle
• Maven dependencies - Similar to Ruby Gems
Build Process - Android Studio
Gradle
• Release & debug resources - automatically merged during build process, no need for templates
• Automated signing & version code incrementing for release builds
• Automatic upload of test builds to Test Fairy
Gradle Build - Config-Specific Resources
android { ! // ... ! sourceSets { debug { manifest { srcFile 'gradle/debug/AndroidManifest.xml' } res { srcDir 'gradle/debug/res' } } ! release { manifest { srcFile 'gradle/release/AndroidManifest.xml' } ! res { srcDir 'gradle/release/res' } } } ! // ... !}
Gradle Build - Release Signing
android { ! // ... ! signingConfigs { release { storeFile file("../my_keystore.jks") storePassword "$up3r$3cr3t" keyAlias "my_key_alias" keyPassword "$up3r$3cr3t" } } ! buildTypes { release { signingConfig signingConfigs.release } } ! // ... !}
Gradle Build - Version Code Increment
def versionMajor = 1 def versionMinor = 0 def versionPatch = 0 !task('increaseVersionCode') << { def manifestFile = file("src/main/AndroidManifest.xml") def pattern = Pattern.compile("versionCode=\"(\\d+)\"") def manifestText = manifestFile.getText() def matcher = pattern.matcher(manifestText) matcher.find() def versionCode = Integer.parseInt(matcher.group(1)) def manifestContent = matcher.replaceAll("versionCode=\"" + ++versionCode + "\"") manifestFile.write(manifestContent) } !tasks.whenTaskAdded { task -> if (task.name == 'generateReleaseBuildConfig') { task.dependsOn 'increaseVersionCode' } }
Gradle Build - Version Code Increment
android { ! // ... ! defaultConfig { minSdkVersion 14 targetSdkVersion 19 versionName "${versionMajor}.${versionMinor}.${versionPatch}" } ! // ... !}
Gradle Build - Test Fairy Upload
buildscript { repositories { mavenCentral() maven { url 'https://www.testfairy.com/maven' } } ! dependencies { classpath 'com.android.tools.build:gradle:0.10.+' classpath 'com.testfairy.plugins.gradle:testfairy:1.+' } } !apply plugin: 'android' apply plugin: 'testfairy' !android { testfairyConfig { apiKey "1234567890abcdef" } } !!gradlew testfairyDebug
https://github.com/testfairy/testfairy-gradle-plugin
Topics
• Development Tools & Build Process
• Libraries Used
• Graphics & User Interface
• QA & Testing
Libraries Used - API (Early 2012 to Mid 2013)
• Apache HTTP Client - API requests
• Ignition Library - Caching & async image loading
• GSON - JSON parsing
Libraries Used - API (Mid 2013 to Present)
• Volley - API requests & caching
Pro Tip: compile 'com.mcxiaoke.volley:library-aar:1.0.+'
• Picasso - Async image loading
• GSON & Jackson - JSON parsing
• Apache HTTP Components - File uploads
Libraries Used - User Interface
• Smooth Progress Bar - Dashed progress bar similar to Gmail, etc.
• Sticky List Headers
• View Pager Indicator
Libraries Used - User Interface
• Butter Knife - View Injection !! @InjectView(R.id.profile_username) TextView username; ! @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.my_fragment, container, false); ButterKnife.inject(this, view); return view; }
Libraries Used - Social Networks
• Facebook SDK
• Twitter4J
• Signpost - Twitter OAuth flow
Libraries Used - Miscellaneous
• Google Play Services - Battery friendly location
• GreenDAO ORM - Much simpler than content providers
• Otto - Event bus, pub/sub messaging between components
• Crashlytics - Crash reporting & analysis
Topics
• Development Tools & Build Process
• Libraries Used
• Graphics & User Interface
• QA & Testing
Graphics & User Interface
• iOS design != Android design - But iOS 7 blurred the lines
• Retina images - XHDPI
• Non-Retina images - MDPI
• Icon font - Scalable icons that can be styled as text
Graphics - Using an Icon Font
1. Use Font Awesome web font or your own font for scalable, styleable icons
2. Map font characters in a strings resource file
3. Load font, apply to TextView or Button subclass
4. Set view text to desired character, style, etc.
5. Bask in the awesome !https://github.com/bperin/FontAwesomeAndroid
Graphics - Icon Font in Layouts
<com.FontAwesome.Example.TextAwesome android:id="@+id/text_prost_icon" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/fa_beer" android:textSize="30sp" /> !!<com.FontAwesome.Example.ButtonAwesome android:id="@+id/button_kaffee_icon" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/fa_coffee" >
User Interface - Multiple Screen Sizes
• Use ActionBarCompat & Nine Old Androids if supporting Gingerbread or lower
• Use RelativeLayout where possible to dynamically position views
• Dimensions in dimens.xml files, different values directories for various screen sizes
• Screen size specific layouts where necessary
Topics
• Development Tools & Build Process
• Libraries Used
• Graphics & User Interface
• QA & Testing
QA & Testing - Devices
• Too many to test them all
• Attempt to test a representative sample
• Major manufacturers - HTC/Motorola/Samsung/Nexus
• After Gingerbread support dropped, OS version & OEM customizations are much less of an issue
QA Testing - Process
• Bugs & features entered in Pivotal Tracker
• Multiple builds delivered for testing each week
• Use Test Fairy test session videos to troubleshoot device specific issues
• Full regression test of RC build before each release
Vielen Dank!
K andydyer.org
n @dammitandy
g plus.google.com/+AndrewDyer
Recommended