Notes from Google I/O 15
Overview
editThe notes here are mostly focused on Android, as it is written by an Android developer. The biggest improvements for Android are in terms of quality and performance tooling, and the M preview announcement.
As usual with conferences where there are many sessions/talk happening concurrently, one cannot attend all sessions/talks onsite. So, some of the sections below related to talks are empty, indicating a wishlist of talks to watch later. Feel free to augment.
Onsite experience
editThe Sandbox talks were only up to 20 minutes long, to allow 10 minutes time to get to the next session, or should I say wait in line. The space was in a somewhat open setting but still enclosed by some wooden structures which let people look through. The allocated spaces for theses were way too small, and overcrowding was a problem at most interesting sessions. Most Sandbox talks will be (re-)recorded, even though it was not apparent. I didn't see any camera at the Sandbox talks, but later learned they will be re-recorded as DevBytes (shorter and no Q&A). It does seem like a long time until all the sessions will be published under "100 days of Google Dev". I only went to a couple of bigger sessions since the most interesting ones were live streamed and available for everybody to watch from home. Even there overcrowding was an issue. One had to stand in line for quite a while. A 2.5 minute highlight reel of on-site experience.
Main videos
editAt https://events.google.com/io2015/videos (Archived 2018-09-16 at the Wayback Machine) you can filter for Android and switch between Sessions and DevBytes.
- Keynote
- What's new in Android
- What’s New in Android Development Tools (to add)
What's new in Android
edit- Samples now on Github: https://github.com/googlesamples
- GCM Network Manager allows to specify criteria when to perform network-oriented tasks (OneOffTask, PeriodicTask), part of Google Play Services :(, uses JobScheduler internally for L+ devices
- Data Binding -> session: Data driven Android UI development
- Android Design Support Library -> Sandbox talk: Bringing Material Design to Life on Android
- CoordinatorLayout, Snackbar, TabLayout, NavigationView, ..., FAB (FloatingActionButton),
- RecyclerView: Swipe to dismiss, drag&drop
- WebView: PostMessage, ..., WebSettings.setOffscreenPreRaster
- Notifications: Icon (was a bit unclear)
- Systrace for ART: get runtime stats
- Adoptable Storage Devices: User can "adopt" insertable SD card as permanent storage; no new APIs; avoid hard-coded paths in code
- Next: "Developing for Android" series: medium.com/google-developers
Android M Preview
editNo official name for M yet. Preview is available for a few Nexus devices only (Nexus 5, 6, 9, Player). There will be 3+ previews this time to incorporate feedback, roughly once near the end of each month. Some of my favorites:
- App permissions
- Individual and delayed Permission requests (instead of asking the user for all permissions at install time, the app asks when a new permission is needed, can be revoked later); M+ devices only, older devices revert to old behavior to ask the user at install time; permission categories have changed
- "Now on Tap"
- Long-press home button to get a single Google Now suggestion at the bottom of screen (so, not full screen anymore) based on what's on your screen right now.
- "Doze" mode
- low-power mode while the device rests
- USB Type C connector support
Links:
- Android M Developer Preview Site: http://developer.android.com/preview/overview.html
- Android M Preview Flashable Images: http://developer.android.com/preview/download.html
Talks about Android App Testing
editI'm excited about the quality tool improvements announced at this IO. Overview of talks:
- Android Studio:
- (session) What's New in Android Development Tools
- Unit Testing on Android
- Android Testing Library:
- Android Testing Support Library
- Espresso: UI Testing for Android
- Cloud Test Lab:
- Mobile App Quality Leaps to the Cloud
- Google Play Testing:
- Smarter Approaches to App Testing
Unit testing on Android
editFor now you need to switch source sets when developing tests in Build variant chooser between instrumentation tests and unit tests. (It's a Gradle plugin limitation). No need to switch when running tests since you can run the from a AS run config or from command line.
Android Testing Support Library: The next generation of Android Testing APIs
editAndroidJUnitRunner (aka InstrumentationTestRunner2)
- finally, JUnit4 and lots of annotations for instrumentation tests :)
- e.g:
@RunWith(AndroidJUnit4.class)
,@SDKSupress(minSdkVersion=18)
,@RequiresDevice
,@SmallTest
,@MediumTest
,@LargeTest
(in addition to the regular JUnit4@Before
,@After
,@Test
) - does not inherit from a base class: but you can use
InstrumentationRegistry.getInstrumentation()
,.getContext()
,.getTargetContext()
,.getArguments()
. ActivityTestRule
for functional testing:
@Rule ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>(MainActivity.class)
ServiceTestRule
- Next:
- Samples: android-testing on GitHub: https://github.com/googlesamples/android-testing
- Docs: https://developer.android.com/tools/testing-support-library
- Codelabs: "Unit and UI Testing in Android Studio"
Espresso: UI Testing for Android
editWhat would a user do?
1. Find a View 2. Perform an action 3. Check some state
- Basic:
onView(Matcher) .perform(ViewAction) .check(ViewAssertion);
Espresso provides lots of Matchers, ViewActions, ViewAssertions, see Espresso cheat sheet.
- Going Deeper:
onData()
API forAdapterView
s- Advanced Synchronization with
IdlingResource
onData(ObjectMatcher) .DataOptions .perform(ViewAction) .check(ViewAssertion);
- Espresso-Intents: like Mockito but for Intents
intenting(IntentMatcher) .respondWith(ActivityResult);
- Espresso-Web: [yay for us heavy WebView users]
"Work with WebView using WebDriver Atoms"
onWebView() .withElement(Atom) .perform(Atom) .check(WebAssertion);
- Espresso Contrib: stuff that doesn't fit into other buckets, and/or is user contributed (GitHub!)
- DrawerLayout, RecyclerView, AccessibilityChecks, ...
Same codelab as above: "Unit and UI Testing in Android Studio"
Mobile app quality leaps to the cloud
edit(caught last part only)
Probably the same as below but instead of using Dev Console this is using Android Studio
Smarter approaches to app testing
editCloud Test Lab in Dev Console: upload apk to alpha/beta channel, then let test run on the top 20 devices Monkey Runner-like test is free, custom tests cost money
Talks about Android Performance
editI saw a bunch of very entertaining session by Colt McAnlis. He's also got several "Android Performance Patterns" videos on [goo.gl/4ZJkY1 Youtube] and [1]. Overview of how to use the tools: https://docs.google.com/document/d/1EKVq2FzcLVJFbwUtaC3QRddSwtzs0BSKZahkQyeGyHo/pub?embedded=true#h.zayu98yotlht
Network Performance & Tooling (Colt McAnlis)
edit- Network Traffic Tool
- JobScheduler, SyncAdapters
- Videos about payload size:
- Posts about payload size:
- Image Compression for web developers (vary JPEG quality level)
- Text Compression for web developers
Memory Performance & Tooling (Colt McAnlis)
edit- Allocation Tracker, TraceView
- When loading Bitmap make it scale down instantly
- use a lib like Glide, Picasso
- ArrayMap uses less memory than HashMap if few items
- Video: DevBytes: The Magic of LRU Cache
Rendering Performance & Tooling (Colt McAnlis)
edit(to watch)
Battery Performance & Tooling (Colt McAnlis)
edit(to watch)
Android Developer Tools: Deep dive into Performance & Build Tools
edit(to watch)
Project Volta: Android battery life
edit(to watch)
Talks: Android Architecture + Data Binding
editAndroid application architecture
edit(to watch) This session was offered twice but so full that I couldn't make it. Will watch online.
Building Apps Faster with Android Data Binding
editWindows devs had this for years. Finally coming to Android. Bind your data in a layout XML file with the regular layout. Code is generated/optimized at compile time. No reflection/runtime used.
Talks: Android Location Awareness
editMaking apps context aware: Opportunities, tools, lessons and the future
edit(to watch)
Building location aware apps using the Android Location and Places APIs
editWith the Places API you can translate easily between lat, lon to place names and types and vv. (Example: Am I at a gym or in a forest?)
Talks: Android Material Design
editAdaptive UI with Material Design
edit(to watch)
Android Design Support Library: Bringing material design to life
editThere have been many 3rd party libs for Material Design. Now there's an official one.
- CoordinatorLayout: coordinates behavior of layout components for nicer animation flows,
- avoid hiding important elements (example: add a FAB to a CoordinatorLayout, ref. the CoordinatorLayout in a Snackbar, then FAB can move away when Snackbar appears)
- CoordinatorLayout + app bar:
Other highlights were already listed above. Here are the details:
- Design library blog post: http://android-developers.blogspot.com/2015/05/android-design-support-library.html
- Android Support Library: http://developer.android.com/tools/support-library
- DevBytes: https://www.youtube.com/watch?v=32i7ot0y78U&index=1&list=PLOU2XLYxmsIJDPXCTt5TLDu67271PruEk
Other Android talks
editUnleashing the power of Android Backup
edit(to watch)
Anyone can do it! Easy ways to evaluate your App’s Accessibility
edit(to watch)
Read more
edit- "Developing for Android" series
Action Items
edit(Compiled while I was watching https://plus.google.com/u/1/events/cn2mln1obrhkuhsfin8sobmi0m4?e=-RedirectToSandbox)
Soon
edit- Try out app on M preview SDK and M preview (virtual or real) device: https://developer.android.com/preview/setup-sdk.html
- Test:
- Android Backup: test on M (app data is backed up automatically starting with M, need to look into excluding files if we need to)
I also found a Backup Test app on the emulator. I used that to backup and restore the Wikipedia app but it failed to successfully restore the backup. Someone needs to look into that more.
- Adoptable Storage Devices https://developer.android.com/preview/behavior-changes.html#behavior-adoptable-storage
External Storage: User can "adopt" a micro-SD card to act as internal storage (users could move the app there); no new APIs; avoid hard-coded paths in code There are no real devices to test this with yet; so for Preview testing on emulators these are the magic commands we should use (could use more info here):
adb root && sleep 2 adb shell setprop persist.fw.force_adoptable 1 adb reboot
- Android Design Support Library (quick wins):
- Change NavDrawerFragment to NavigationView Done
- Change croutons and several toasts to Snackbar Done
- Change EditText to TextInputLayout (wraps EditText; hint text floats above when focused or not empty; errors appear below) Done
- Consider using new Support annotations: TODO: compile a list that makes sense. A presenter said that some annotations are not necessary for the app dev to add since the base classes in the system libraries already have them. I believe he was referring to @WorkerThread and @RequiresPermission. Partially done
- Figure out what we want the new floaty long press contextual action bar thingy to look like.
Merge around the time when M is released
edit(or keep a WIP patch around for a couple of months ;; requires targetSdkLevel 23)
- Add code to request permissions at runtime, see also:
- IO session "Permissions in M: Best practices for developers"
- https://developer.android.com/preview/features/runtime-permissions.html
Upcoming support library
edit- VectorDrawables
[Ok, I didn't actually see this at Google IO onsite, and this exists since Lollipop, but since I ran across this while watching some DevBytes, I wanted to add some notes about that.] VectorDrawables allow icon resources to be packaged as XML (subset of SVG) instead of multiple PNGs. You can't used SVGs directly, but there are tools which let you import SVG files. BTW, there is also an animated variant (like and animated GIF, ehm, SVG). Unfortunately, VectorDrawables are currently only supported on devices running Lollipop or newer. There are already a few libraries trying to fix this and there seems to be a VectorDrawableCompat in the works. :) Let's check that out when it is available. This could make our apk leaner. We could just change our convert-icons script to use one of those tools instead. http://stackoverflow.com/questions/26548354/vectordrawable-is-it-available-somehow-to-pre-lollipop-versions-of-android https://github.com/android/platform_frameworks_support/blob/master/v7/vectordrawable/src/android/support/v7/graphics/drawable/VectorDrawableCompat.java How would it would deal with RTL you ask? There is a flag we could set in the VectorDrawable XML: android:autoMirrored. :D You can also set a android:tint in the root node of VectorDrawable XML to easily customize the SVG for our color palette / theme.
Maybe later
edit- Consider RecyclerViews instead of ListViews: if we want swipe to dismiss or drag & drop; initially for new functionality, no need to change if ListView is working for us
- Consider CoordinatorLayout Done for FAB
- DirectShare: implement ... ChooserService
- Consider Voice Interactions
- More control over word break in TextView
- new Icon class promises to reduce memory use (Icon.createWithBitmap())
- App linking: consider adding statements.json to web site and auto-verify flag to AndroidManifest.xml
- http://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#FLAG_SECURE prevents screen to be accessible for screenshots and to Now on Tap Assistant, but user could also disable Now on Tap Assistant
...