Sebastian Vieira and Vikram Kriplaney examine the state of Android and iOS in 2016 from App Builders CH. Join them as they talk iOS for Android developers and Android for iOS developers. What are the similarities? What are the differences? And how can you become a mobile ninja by mastering context switching?
Xcode (1:19)
Xcode is the IDE that we use to develop for iOS. It’s got an awesome set of tools, except refactoring, which we miss completely. But besides that, it’s much more than a source editor. You do much more than just write Swift and Objective-C. It even has built-in particle system editors, 3D scene editors, and you can develop your apps with storyboards, which is a visual connection between the views and your code. That’s something we miss on Android.
Android Studio (2:14)
Android Studio is a very powerful Java IDE. It was introduced about two to three years ago, as a collaboration from Google and IntelliJ. It plays nicely with a lot of Google Play Services such as App Engine, or App Indexing. It has strong support for testing, but unit testing was still beta as of last year. What’s not poweful is the layout editor, and the translation resources.
Android Emulator (3:00)
The Android Emulator has improved on a lot with inter-native support. Compared with the iOS simulator, there are a number of things you can do that the iOS Simulator cannot. For example, starting a phone call, or using the camera. There is also Instant Run, which is a new feature that lets you compile little bits of your code and instantly deploy them, without having to go through the compilation process.
iOS Simulator (4:27)
The iOS Simultator is much faster than the Android one, because it’s not an emulator. It’s basically an i386 Mac OS app. The simulator cannot access the camera, but a lot of other things can be simulated, including how the graphic rendering is working, locations, localizations, and iCloud integration. It still can’t simulate force touch unfortunately.
Translations (5:36)
Android Studio
Android Studio has an awesome translation editor. It can tell you when don’t have some translations, and you can even order a translation straight from your IDE to get it translated professionally.
Xcode
Translating iOS apps, on the other hand, has always sucked. There’s an obscure set of tools including command line tools, and these exchange formats that Apple advises to use. I started using Google Sheets to do simple translations, and I found Google Translator built in.
I can use formulas to assist in translating the strings with the keys. If something is a bit off, I can replace the formula. You can also share the spreadsheet and have collaborators to help you translate.
Package Managers (10:45)
Android
Gradle is a fully-fledged build system, natively supported by Android Studio. First, you’ll always have dependencies that are outdated. If you want to start playing with fancy stuff on the new versions of Android, you can enable data binding on Gradle. It’s recommended to increase your heap size, so that it goes faster. You can also enable Jack, which is the new compiler that Google has developed and is going to replace the previous compilation system.
iOS (Third Party Libraries & Dependencies)
For iOS there are two real choices, and one future choice, in terms of dependency management. The one we choose is CocoaPods, but there’s also the choice of using Carthage.
Some new developments in the Swift community. The Swift Package Manager, which still doesn’t support iOS, will have some impact in the future.
That’s a new testing framework in iOS. Previously, you had to use instruments, and write script with JavaScript. But now, with the Xcode UI framework, you can write your tests with real, compiled code. Using Swift, you can assert that if your buttons exist in the interface.
Submitting Your App (16:30)
Android
I wanted to give a quick word about ProGuard. For all Android developers here, I like to put out a reminder to always use it. It not only makes your binary size smaller, but it also obfuscating the code, so it prevents other people from being able to decompile your application.
Code Signing on Android is easy. You just need a Keystore with a private key:
release {
storeFire file("_market/android_market.keystore")
storePassword "android"
keyAlias "androiddebugkey"
keyPassword "android"
}
The Google Play Developer’s Console is awesome. I personally think it beats iTunes Connect by quite a big margin. There is no real app review process. They try to involve humans in the whole review process, but are still playing catch-up with Apple.
iOS
The fact that Apple takes its time to review stuff on iOS is kind of just a filter to prevent trivial “Hello, World” apps from making it into the store. With Apple you get that reassurance or some semblance of quality. Sometimes, it’s a bit despairing, when you really want to get that urgent bug fix out there and you have to wait for review. You can request expedited reviews from Apple, but you have to use them sparingly and carefully. Most of the time they do oblige.
You can now set up internal testers in iTunes Connect, which can then get your app. You can also set up up to 2,000 external testers, merely with an email address. You can then onboard them onto your external beta testers. That works pretty well, but we do miss the gradual releases that are possible with Android.
Cloud Test Lab (21:30)
Android
Google just released a big data center, with a lot of phones, were you can just deploy your APK, and run instrumentation tests on it, and you can do Robo tests. A Robo test is a test if you don’t have real tests, in which basically, your application gets to run automatically. You get the log files with crashes, if any. You can define the device metrics and test on multiple devices, and you can do all this from Android Studio.
iOS
What fragmentation is there on the iOS ecosystem? Essentially none. Most developers can get away with three to four devices for testing.
iOS 9 penetration is at 84%, and iOS 8 is at 11%. That means if you can follow the best practices of supporting the current major and the last major version, then you’re already targeting 95% of your users.
To note, I don’t think Google really cares much, whether you’re on Android or Android N. What they care is you’re running the latest version of Google Play Services. There, the penetration is pretty much close to 100%.
Inter App Communication (24:40)
Intents in Android
Intent is basically a communication layer. It lets you launch activities, make broadcasts, or talk to services. In a way, it’s one of the most powerful features of Android. It lets you have a variety of applications talking to others, and reacting to events. Take, for example, Tasker, a very commonly used Android application. With it, when I plug headphones into my Android device, I get Spotify launching, immediately.
iOS
On iOS, integrating with other apps is much simpler. On iOS, there is an idea of URL schemes, or if you know the scheme that another app supports, you can launch it, and potentially pass some parameters. For instance, you can trigger a query.
There are other ways to communicate between apps since iOS 8, and that’s with extensions. There are all kinds of extensions, including custom keyboards, but the one that we’re more familiar with is Today widgets. You can slide down in the Notification Center and see what the next departures are around you, or ad-blockers, which we’ve had some experience with. Those are the things you can expose, from within your app, for integration with the operating system.
Widgets in Android
On Android, there are widgets. A widget is basically a remote view that is trying on the hot spot process. They are very limited, and it’s got a very small set of UI elements. In a sense, it’s basically a BroadcastReceiver.
Programming Languages (26:57)
Java
Android supports Java, which is something that I love, but some people think it’s boring. I’ve heard it called the German of programming languages. You don’t have to use Java to program for Android. You can use Scala, and more, such as Kotlin
Kotlin
There’s a new modern programming language, developed by IntelliJ called Kotlin, and you can run a plug-in to your Android Studio IDE. With it, you can import XMLs, and then, with all the data binding, everything happens magically. It’s similiar to Swift.
import kotlinx.android.synthetic.main.activity_main.*
public class MyActivity : Activity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
textView.setText("Hello, world!") // No need for findView(R.id.textView)
}
}
Swift
If ever you could fall in love with a language, it’s Swift. There are lots of modern features, including optionals, higher level functions, it’s protocol-oriented, and best of all, it’s now open-source.
Graphics (29:20)
Vulkan
Android is soon going to introduce Vulkan, a low-level 3D programming language API, introduced by Khronos Group, the guys behind OpenGL. There will be some nice games coming soon to Android because of that.
Metal
Apple’s answer to Vulkan is Metal. According to Apple, it’s 10 times faster, and you get some really amazing performance. That’s because it’s much more low-level, so it’s really speaking to their A7 chip, directly.
App Indexing/iOS Continuity (30:07)
App Indexing, basically, is a way for Google to crawl your app, and associate your app with search results.
Similar to that on iOS there’s deep linking. In your app, you declare the domains that map to your app, you put those in the entitlement. On the domain, on the web server itself, you host this Apple App Site association file, which maps URLs in your website, to the app. There’s another part of continuity, which is Handoff. It’s probably easier to explain it with code.
// Updates the given user activity or creates one for this entry
func updateUserActivity(activity: NSUserActivity? , ... {
// Handoff support (since iOS 8.0)
activity.title = title
activity.userInfo = [kDetailActivityEntryIdKey: entryId]
activity.webpageURL = myWebpageURL
// Enable Handoff, Spotlight and public indexing
activity.eligibleForHanoff = true
activity.eligibleForSearch = true
activity.eligibleForPublicIndexing = true
})
Other things you can do with that activity is make it eligible for Handoff. That means you’re looking at say, a detailed view on the local app, you then go to your Safari browser. It’s already waiting to give you the same webpage, that is equivalent to that content. You can further make it eligible for search within Spotlight. If you enable the third flag there, the eligible for public indexing, Apple promises that there is a public index. If your detailed view, or entry view, or whatever thing, that activity is popular enough, it’ll start surfacing on devices that don’t have your app installed. That could lead to downloads, that could lead to people going to your website.
Permissions (32:33)
Permissions on Android can be a pain, because a lot of stuff has to be done manually, and only the activity can get the callback. You’ve got a lot of conditional code and there is no real way to know if you already asked for a permission.
I wish Google had done a better job with it, but on the other hand, it’s pretty powerful. It gives more sense of security for Android, and puts it on par with iOS. But, Android really shamelessly copied the iOS model of permissions.
On iOS, we’ve always had this idea of asking for permission when the time is right. When the user is in the context of the permission that you want to ask for. There are currently many more granular permissions you can ask for. There is location, contacts, notifications, HealthKit, Bluetooth, and you get a chance to explain why your app wants it. That’s the model to follow, I think.
New for 2016 on Android (34:33)
Data Bindings
Android will have data binding, which is awesome. It’s a way of saying goodbye to findViewByID
. It lets you not only associate views with XML with the code, but also perform actions.
There’s a similar language, called Expression language, very similar to Java, which lets you write code in your XML. One of the advantages from Android, is the fact that the XML on the views is so simple that you can edit manually. I don’t even know how many times I had conflicts while trying to merge a storyboard in iOS. It’s been always a pain. So, you can just import the XML.
Battery Life
Other features that are coming to Android N is improvements in battery life. Not just when you go to bed and put your phone in your desk, charging will it stop doing operations. There are maintenance windows, in which when you have your phone in your pocket, your phone will wake up, and dedicate that maintenance window to just doing network operations, whatever.
Multi Window
You will be able to run on a tablet or a phone, two applications together, in parallel. They’ve added new flags to Intents, like Flag Activity Launch Adjacent. Before we had fragments, now you can even have activities running together with another activity, at the same time.
New Notifications
You will see notifications look totally different. They are supported by previous versions of Android N thanks to notification compat library, but you will be able to do things like grouping notifications, when you get multiple emails or multiple chats. You can even directly reply from notifications.
Direct Boot
There are fast, funky features, like Direct Boot. Imagine your phone is encrypted, and it’s booting. What happens if you have an alarm clock application, and your phone restarts while you are sleeping? On Android N, you are out of luck, because since the device is encrypted, the application won’t be able to start.
With Direct Boot, you can have the ability to define an application that can be virtually launched, even before the phone is unlocked and encrypted. If you are writing an alarm clock application, you will be able to use this feature, and it will work on Android N.
Scoped Directory Access
They are adding new permissions on Android N. If you want to access your photos in the past, you had to ask for access to external file system, or internal file system. Now, you can ask for other parts of your file system, like the directory pictures, and you will get a nice notification, asking for permission for that specific directory.
On iOS, it’s basically all Sandbox. You can’t access the file system as you would on Android. What you can ask for permission is to access your photos, that’s the only place. Of course, now you have a document model that allows you to share, between apps.
Context Switching/Mobile Ninja (42:00)
There is this concept of the mythical context switch when trying to do both Android and iOS development.
In the beginning it might be there, when you’ve come from iOS and vice versa. But, the more often you do it, the less of an impact that context switch becomes. It can be even good. All I can say is, the context switch actually keeps your brain functioning better.
As a tip, what I usually do is, at work I focus on Android code, and usually when I go home and I want to spend some time hacking, I hack on iOS. When I’m fully focused on iOS at work, I try to hack some stuff on Android when I’m home. If you don’t have this luxury of switching between platforms at work all the time, at least you can always try to juggle with all platforms at the same time. Do both. You learn from each platform. You’ll be able to bring concepts from one to the other, and become a Mobile Ninja.
Receive news and updates from Realm straight to your inbox