Spoiler alert for those who cannot bare reading two paragraphs: it all ends well and my new silly app ends up in iTunes! Continue reading
This post is about never-ending pursuit of STR… Steps To Reproduce.
How often do you get a bug or issue report with no useful steps to reproduce it? Often I bet. The bug would be something as vague as “something broke”. Thanks.
I don’t know about you, but I find it very annoying. This is more true on Android than on iOS.
If you’ve ever ventured outside a small project that shares code between iOS and Android you would have realized that the JNI part of the share is the most tedious and at times painful. Hand-coding JNI by hand is a real pain, a lot of things go wrong: unbalanced releases, uninitialized fields, tweaking signatures as you progress with development, etc. This takes a lot of time which we are trying to save in the first place. If these sound familiar it’s likely you are sharing, or trying to share, a real object model across platforms, not just a collection of strings…
The Play2 starter template for iOS, Android and command line is a good idea if you are hitting multiple point on this list
We are getting closer to the truth. At least my version of the truth…
Very soon we will be able to share code between iOS and Android. Without commercial libraries. With 100% of source available. With only some pain.
Yes, there will be pain, so prepare!
I’d say about 4 or 5. Your pain tolerance may be different.
In future posts I will outline a less painful way to share, but it’s a good idea to go though details of this post to see what elements are at play.
The instructions that follow below may be applicable to you if you are hitting some of these points
- You are starting a new app that needs to work natively on iOS and Android, maybe even on Mac/PC desktops
- Your iOS apps are getting converted to Android
- You always wanted to write something in C++ , but were afraid
- You are very brave and have an unbounded curiosity and patience
If you missed the beginning of this, and landed on this page somehow, and something is not clear, read this link first – with pictures too!
First thing is first. You need to make sure you have Android NDK installed and available in PATH.
Modify your .bash_profile or .profile to export PATH and setup ANDROID_NDK variable. Something like this:
And then in a new terminal window try executing command line:
Play1c is a starter project that is meant to explain how to share code, the data layer especially across platforms. It’s a set of minimalistic apps for iOS and Android that you can use as starter apps for your own projects. Start with Play1c and start renaming, changing, adding, and hacking.
Quick Start – The Short Version
Make sure you have Android NDK installed and ndk-build available. The NDK needs to be in the PATH.
git clone https://github.com/yevgenyk/Play1c.git
iOS and OS X
ios-search.xcodeproj is the iOS project, it should just work
tests.xcodeproj is the OS X unit test, set up a new scheme, and point working directory to tests subfolder
in terminal, run ndk-build
which will build the native shared libraries used by the android app
in terminal, run ./gradlew assembleDebug
Optionally enable buildNative command line building by providing a full path to ndk-build inside app’s build.gradle
The longer version – for people who can read a few paragraphs – with pictures!
http://codingsimplicity.com/shared-c-layer-with-objective-c-and-java-using-jni-tutorial-part1/ – the iOS and OS X, part I
http://codingsimplicity.com/shared-c-layer-with-android-using-jni-tutorial/ – the Android, part II
From the start the concept seems interesting. Write some code in plain Java, run it though a translator, which will generate some objective-c equivalents calling into the framework’s JRE emulation library. It all seems legit.
So I go and compile the “Hello world” example and yes it works, the excitement is still there, so let me try something more useful than a “Hello world”. Since I’ve been into “pull to refresh” apps lately, and I need to keep going with those I will try to pull down some JSONs down! Yeah!
Full disclosure first. I have never worked for Microsoft, mostly for logistical reasons of Microsoft campus being on the wrong coast, but I have always been their fan. Because of Visual Studio mostly… and .NET
It’s sad to see .NET lose its momentum in favor of other technologies, but it’s still alive and kicking, mostly on the enterprise side.
Reviewing Xamarin is easy. Even being a .NET fanboy and liking the technology it gets ruled out right away.
After years of writing iOS apps and backends I have finally ventured into Android development. Yes, I’m a little late to the party, and yes, it’s quite different from iOS development, not in terms of programming constructs, but in terms how it feels.
So I jump headlong into Android, plowing though samples, occasional reading, and bug fixing someone else’s code. It’s all good.
Majority of my initial involvement with Android has to do with the things I already know well. Persistence, business logic, downloading some JSON from the network, serialization, search, pagination, etc.