Introduction
Not long ago Intel announced the Multi-OS Engine at the Android Developer Conference (Andevcon) 2015, Boston. It enables you to develop native mobile applications for iOS and Android with Java.
Developing native mobile apps that work on both iOS and Android isn’t easy – or cheap. You could build two separate native apps to get a native look and feel at a greater cost:
However, even for large companies with significant resources that choice proved to be difficult. That could be changing. Developers now have the chance to preview Intel’s Multi-OS Engine (MOE), which is designed to drastically reduce the development time needed to build separate native iOS and Android apps:
Multi-OS Engine provides a comprehensive solution to your cross platform needs.
Why be native is so important?
Modern mobile users are very tempted. App stores for any platform are filled with a huge number of clones. How to stand out among them? I would rather choose something that looks and feels more consistent with the rest of the platform. Even though developing native mobile apps takes longer, native Look & Feel is exactly what end users are interested. So saving on this is simply impossible. For several reasons native applications have a significant advantage in this area:
- Direct access to platform-specific UI components, like navigation stacks, date and time pickers, maps and etc. It's possible to reimplement these components on the web, but our reimplementations never feel exactly like their native counterparts, and they also don't get updated automatically with changes to the platform.
- The lack of overhead related to the UI rendering.
- Native multithreading. Web based frameworks don't allow to parallelize the application as good as it possible with native code.
Why Java?
GitHub’s ranking of languages based on the volume of code stored in its repository clearly explain Facebook’s choice of Javascript for React Native and Intel’s choice of Java for Multi-OS Engine as the cross-platform language:
One of the major reasons why Java became so popular is the vast amount of existing code such as libraries, examples and open source applications, that is available to Java developers.
Technical Overview
The Multi-OS Engine is available as a stand-alone plug-in that can be integrated into Android Studio. App projects can be started as simple as Android projects in Android Studio and Multi-OS engine configures the project to build and run as an iOS App on the iOS simulator that can be invoked from Android Studio as well. Thus you don’t necessarily need to know Objective-C to build your native app for iOS. Herewith Android development doesn't go through any changes. Further, you have a wonderful opportunity to reuse all the platform-independent code. MOE does not offer a 100% reuse of code. But this value can reach 60% with proper application architecture.
Multi-OS Engine facilitates Java support on iOS through:
- Auto Java binding generation from Objective-C and C header files from existing libraries or 3rd party packages
- Java annotations and NatJ runtime library
- Eliminating the need to write JNI functions
- Prebuilt jar files interfacing iOS API are provided in MOE
So you can start coding iOS app in Java immediately!
iOS Development Workflow with Multi-OS Engine
These steps explain only the creation of iOS App with Multi-OS Engine, assuming that you are aware of the build process of an Android app in Android Studio.
- Create an Android Project in Android Studio and to include configuration for iOS app, add new configuration “Intel Multi-OS Engine Project”.
- Design UI for iOS in XCode or Multi-OS Engine’s UI designer in Android Studio
- Bind UI to Java using the NatJ runtime libraries.
- Android Studio is equipped with the Intellisense capabilities to bind the action handlers to the UI elements for iOS.
- Local build is supported on OS X development machines where iOS Simulators can be invoked. For Windows development systems, remote/cloud build is supported.
- iOS applications then can be run on the Simulator which is integrated into Android Studio by Multi-OS Engine configuration or directly on the device itself.
- Debug your iOS applications directly in the Android Studio.
Code snippet
If you are a experienced Java developer all this Objective-C stuff can be confusing:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"showDetail"]) {
NSIndexPath *selectedIndexPath = [self.tableView indexPathForSelectedRow];
...
}
}
Now just imagine the same functionality coded with Java:
@Override
public void prepareForSegueSender(UIStoryboardSegue segue, NSObject sender) {
if (segue.getIdentifier().toString().equals("showDetail")) {
NSIndexPath selectedIndexPath = getTableView().indexPathForSelectedRow();
...
}
}
It looks pretty similar, isn't it? But it's much more familiar for the Java developers. This is meaning that you can easily port any UI related Objective-C code to Java and focus on the business logic of your specific application.