Sunday, October 6, 2013

Starting With Android Studio

Over the summer, well at GoogleIO, Google introduced a new way to develop apps for Android, called Android Studio. Android Studio is based on IntelliJ instead of Eclipse. I've been using Eclipse for 7 years, so this change might be a challenge.

The install was really straight forward. Everything is on The link about halfway down the page will have the various install packages, one for Windows, one for Mac and another for Linux. The only thing these packages don't include is the JDK.

I had a JDK6 installed on my Linux box, and was able to install without any issues. I adjusted my PATH environment variable in the bashrc file, and everything worked the second start (the first start complained about double something being created). seems generic, but that is what they use.

Once it came up, there was the tip of the day, and then a warning that there is a new update. There wasn't anything obvious about the update, and how to get the update. I clicked on the "more info" button, and it said to go to help->Check for updates in the menu. I clicked that, and it offered "get updates and restart". The studio GUI went away for about 2 minutes, and gave me status of what is happening. Applying patch was the longest part.

Once it comes up, it starts with a prebuilt app called "My First App". Not sure what it is, but it is a place to start.

The developers page has a link to some tips. These tips offer easier ways to do some editing, and navigation using control keys like emacs and other editors.

The layout editor give an easy start, but isn't intuitive. I added a button, and it looked like it was attached top and center. When I re-sized the button, it jumped to the upper left. The proper way to re-size the button was to change the text and font. I'll have to play with that a little more, so I can figure out how to align buttons and such (assuming I have an app with many buttons).

Most of the default devices are Nexus, and generic low resolution ones. I don't think a 5.4" screen will likely come in 480x854 pixels. I created a Galaxy NoteII with a 5.5" screen at 1280x720 pixels, since that is a phone I use. It doesn't reall matter, since whatever you create will just change presentation on the different devices.

At the top of the edit area, are tabs for the editable stuff, and at the bottom are the tabs for the view. The view can be changed between "Design" and "Text". Design is the drag and drop part. Text is the place where the XML and Java are edited for the project. The java code is where the callbacks and such go. The XML is where the properties of the display is set. While much of the screen layout can be adjusted in the drag-n-drop section, sometimes certain tweaks require editing the XML.

Building is easy, pressing the build menu, and selecting make project will create a set of executables that can be used to build an APK file. The APK file must be signed with a given key. Either a self signed key, or an official key from a register can be used. To self sign an app for testing, you can use the Keytool.

Once your app is running in the emulator (and maybe on a device), the adb tool can be displayed. Selecting on the Android in the bottom part of the frame, or selecting run->debug from the top menu, will enable debugging.

This is a powerful tool. Android Studio has many options, and will take some getting used to. It may not happen the first time you use the tool, or the second time, but it will be a good tool to use.

Give it a shot!

No comments:

Post a Comment