Play2 – starter project for iOS and Android using Dninni and Gyp

Published by:

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…

Play2 is a superset of Play1c. It offers automatic project and makefile generation using gyp and automatic JNI layer generation using Djinni.

The Play2 starter template for iOS, Android and command line is a good idea if you are hitting multiple point on this list

Continue reading

Shared layer between Objective-C and Java (Start Here)

Published by:

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.

Continue reading

Shared C++ layer with Objective-C and Java using JNI – Tutorial – Part 1

Published by:

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

Continue reading

Shared C++ layer with Android using JNI – Tutorial – Part 2

Published by:

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:
Continue reading

Play1c: reusable, hackable starter project for iOS and Android native apps

Published by:

Introducing Play1c

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

iOS and OS X
cd ios-search
ios-search.xcodeproj is the iOS project, it should just work

cd app/src/main/jni
tests.xcodeproj is the OS X unit test, set up a new scheme, and point working directory to tests subfolder

cd app/src/main/jni
in terminal, run ndk-build
which will build the native shared libraries used by the android app

cd 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! – the iOS and OS X, part I
 – the Android, part II

Continue reading

Sharing code between iOS and Android using j2objc

Published by:

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!

Continue reading

Code sharing using Xamarin

Published by:

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.

Continue reading

Reusing code between mobile platforms

Published by:

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.

And then it hits me!
I’ve already done all of this before! On iOS version of the app!

Continue reading