sábado, 5 de novembro de 2011

Getting started developing for Android

So, one day you woke up and decided "I wanna program for Android!", that's actually pretty smart. The mobile market is growing and although some people state the android market in particular is bad (that's an subject for later, though ), I still believe it's a good idea.

Don't know what Android is? http://en.wikipedia.org/wiki/Android_(operating_system) Wikipedia is your best friend!

I have some good news for you. It's absolutely free to start programming in Android. You just need to download some stuff and you can start programming.

You have to begin somewhere

You download the SDK (Starter Development Kit) in the link below:
http://developer.android.com/sdk/index.html 
That little green robot is the Android's mascot. He's not a robot though, he's actually an android. Why did they choose an android to be the mascot? Beats me.

After your download is done (but before installing), go here: http://developer.android.com/sdk/installing.html
You should just follow the procedures in the site and everything should be fine. And before I forget, take the Eclipse path!

About Eclipse:
Eclipse is an IDE( integrated development environment ) that will make your life easier when programming for Android, among other things.
So maybe you like Netbeans( another IDE )? Don't use Netbeans for Android! Google itself supports Eclipse for Android and maybe other IDEs can hold a candle to Eclipse, but if you try using Netbeans and it's plugin, you're inviting headaches. Believe me, I have tried!
If you don't even know what an IDE is, get Eclipse and find out by yourself how much easier it makes your life!

Will problems happen? Maybe. Just comment in the blog and I'll try to help you out!

Some known problems:
  • Try to install the SDK in a folder that has NO WHITESPACES, since that may cause bugs, maybe on the main folder of your hard disk( C: , most likely).
    • The reason for this? I have no idea.
  • You have the JDK(Java Development Kit) but Android SDK Installer says you don't. Well, just hit back once and advance. It should work.

Afterwards you can try to setup the Hello World example.

Ok, now what?

Congratulations if you have setup the SDK, got the emulator running and everything.

Just so you know, Android uses Java as an programming language. I believe that at this point, you have 3 choices:

  • Java is a popular, useful language. Why not program in Android AND some basic Java at the same time? Skip this if you already know some Java.
  • If you want to program any type of application in Android( not just games ), using the native UI( user interface ), maybe get some money in the Android Market, then you should study some basic android:
  • Wanna program for Android solely for games? Then it's better to jump in to a framework straight ahead!
This is Android's native User Interface
But first, what is this native UI that I speak of? It's the default buttons and interfaces that Android comes packed with. You should use them for creating some basic applications, since it saves time and the users are already used to them. You can try to design a game using those things, and while it is possible, it's not a good idea at all, because you'll have little control over rendering (the drawing of your game's graphics), which is BAD, among other problems. And I speak of experience, I've already made that mistake. More about that later, though :D

By using an Framework for games, somebody else has already optimized and organized the way you should handle rendering, input and sound, among other things, which means you'll face less problems trying to design your games and fighting bugs.

One of those Frameworks is AndEngine!

http://www.andengine.org/

Which is pretty well established already and uses OpenGL (Open Graphic Library) , which is a great skill to start picking up. I've never used AndEngine, though. Instead I'm using another Framework... Libgdx.
http://code.google.com/p/libgdx/  
It has a huge trump (for me, anyways)... You program your game once, and it runs on both Desktop AND Android! And since it's Java, that means both Windows and Linux, and maybe anything that has the necessary Java Virtual Machine. Or maybe an Applet straight from the browser? You can do that too! Awesome. It uses OpenGL, like AndEngine.

Frameworks, I'm an expert, I'll make my own!
So maybe you wanna deeply learn Android games mechanics, maybe create your own framework to use in your games, giving you max control and max learning?
Then go program some stuff, get to know a lot about basic Android programmin... And then, start learning about this little guy:
http://android-coding.blogspot.com/2011/05/drawing-on-surfaceview.html

It's called a surface view. It's basically a way for you to control the rendering process completely! If you have this down(you're gonna have to know some threads, so it takes advanced Java), you'll be able to create a good framework. Just search up "SurfaceView Android" on Google and you'll get a lot of stuff.

Uhnnn, I wanna make my own Framework, but...

So maybe you don't know anything about Threads? And you wanna make a pretty good Framework? You wanna have some guiding light? Then I have a book just for you...

http://www.amazon.com/Beginning-Android-Games-Mario-Zechner/dp/1430230428

It takes you step-by-step in to creating a framework in Android and also through creating games(there are 3 game examples made through the book). It's a great read, from the creator of libGDX.

You don't have the money, though? You can still look at his Source Codes as he progresses through the chapters, building frameworks and games:

Look up SVN if you don't already know what it is, to download all the codes at once.

Woosh... I'm tired.

Well, just go program now!

Nenhum comentário:

Postar um comentário