Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Objective-C and Android [closed]

Tags:

I've just finished a relatively large project for the Android, and it's left a bitter taste in my mouth with the knowledge that it will never run on one of the most ubiquitous handsets this side of the solar system (the one by that fruity little club).

So, for my next project, I want to write it in a way that makes most of the components easily transportable between the iPhone and Android platforms. The way I'm thinking of doing this is by coding most of it in Objective-C, and then adding the platform-specific parts in more Objective-C and Java respectively. On the Android side, this will require using the the NDK.

My knowledge of C is good, but my knowledge of Objective-C is close to zero, and I have no desire to learn C++. How sane is the approach above, and is there a better one? Is there any way I can code in Java and still reach the un-hacked iPhone market? And how likely is it that the people I know (iPhone users) will have an Android phone by next year?

like image 742
Tom R Avatar asked Mar 06 '10 21:03

Tom R


People also ask

Does Objective-C work on Android?

"You cannot run Java on iPhone, and you cannot run Objective-C on Android."

Can C be compiled in Android platform?

Android is based on Linux Kernel so it's definitely possible to compile & run C/C++ programs on Android. C is quite cross-platform , so a C Program written in Windows can Run on Linux ( and android ) and vice versa.

Does Apple own Objective-C?

In 1995 a failing Stepstone sold the total rights for Objective-C to NeXT, which then went to Apple when it acquired NeXT in late 1996.

Can I use Intellij instead of Android Studio?

No. Android Studio is focused specifically on Android development and provides streamlined environment and project setup, but otherwise all of its features are available in IntelliJ IDEA.


2 Answers

Step back and think about what in the end you will logically be able to share.

The UI models are fairly different, the components are different. In the end what you might be able to share is data object classes, possibly some algorithms. It's not even like you could realistically end up sharing network code as in the old days because you aren't directly using sockets, you are using HTTP libraries.

So will all of the effort you are putting into this really find a payoff in the end? It seems to me the end result will be a brittle mess that is hard to update, and is mediocre on both platforms instead of being great on either.

Why are you writing applications? To make life easier for you, or your users?

like image 130
Kendall Helmstetter Gelner Avatar answered Oct 03 '22 16:10

Kendall Helmstetter Gelner


Others have said basically this, but I'd like to make it more explicit. Your best bet is probably to write:

  1. Cross-platform data models & core logic, using:
    • bits of GNUstep (Obj-C), or
    • CF-Lite (C), or
    • Whatever you'd like, as long as it's cross-platform :P
  2. iPhone-only interface code, using Cocoa Touch (Obj-C)
  3. Android-only interface code, however they do it for the Android.

That's as close as you can get; any attempt to write cross-platform interface code will undoubtedly result in a mediocre app on both platforms. But making all the rest of your code portable and just wrapping a device-specific interface around it is done all the time and has been worked great for some iPhone developers.

like image 43
andyvn22 Avatar answered Oct 03 '22 15:10

andyvn22