Category Archives: Android

Odd-sounding warning in Git is not a big deal

As I am preparing to make my first commits to our project, and I get bombarded with several of these warnings, one for every changed file:

warning: LF will be replaced by CRLF in res/layout/activity_main.xml.
The file will have its original line endings in your working directory.

I have no idea what this means. Luckily, Google had my answer here: LF stands for line feed, and is what Linux systems use to delineate newlines in files. CRLF stands for carriage return line feed, which is what Windows uses for newlines. That makes sense as I am working in Windows. It looks the impact of this change is pretty insignificant and the warnings can be disabled by entering the following in the Git shell:

git config core.autocrlf true

From the blog Code Your Enthusiasm » WSU CS by Jon and used with permission of the author. All other rights reserved by the author.

My First App

I never mentioned in my previous post that I have been watching www.thenewboston.org ‘s video series throughout the past few weeks.  He’s a young guy and it’s kind of funny learning from him sometimes, weird little things bother me sometimes, I’m weird, it’s weird.  But!

I wrote my first app, you can push a button to add or push a button to subtract! Can’t wait to publish it to Google play..  It’s a good building block to start from.

————————————-

<?xml version=”1.0″ encoding=”utf-8″?>
<LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android&#8221;
android:layout_width=”fill_parent”
android:layout_height=”fill_parent”
android:orientation=”vertical” >

<TextView
android:id=”@+id/tvDisplay”
android:layout_width=”fill_parent”
android:layout_height=”wrap_content”
android:layout_gravity=”center”
android:gravity=”center”
android:text=”Total =”
android:textSize=”45dp” />

<Button
android:id=”@+id/addButton”
android:layout_width=”250dp”
android:layout_height=”wrap_content”
android:layout_gravity=”center”
android:text=”Add One”
android:textSize=”20dp” />
<Button
android:id=”@+id/subButton”
android:layout_width=”244dp”
android:layout_height=”wrap_content”
android:layout_gravity=”center”
android:text=”Subtract One”
android:textSize=”20dp” />

</LinearLayout>

——————–

Does wordpress not have a <code> tag? Gross.

But, that’s XML a lot of referencing android:layout, or just android in general, who would have thunk it?!  XML seems pretty straight forward, oddly enough the day after I learned some of it I had to write it a bit for my internship, which was pretty cool.

From the blog jamescelona » WSU CS by jamescelona and used with permission of the author. All other rights reserved by the author.

First Week install/configure

It’s been a slow start to the project, nice weather tends to do that to me.  I manged to find a great video series about Android development that really starts from the ground up.  Actually, it’s kind of boring at times when he begins to talk about what’s going on in the Java code he’s typing, the XML I am lost but the Java is pretty straight forward (for now).

I have mixed feelings about using Eclipse for this project, I think it will come in handy most of the time but, it’s really bloated.  I like Gedit, or I guess notepad++ for windows.

I watched the first videos, downloaded Eclipse, downloaded everything I needed, John wants to work on Android 4.03 since his phone will be able to use it.  It’s going to work fine but, just won’t be available to as many people considering it’s a much newer version than the API level 8 that was suggested in the video series.   The videos came in handy since I thought it was always kind of a pain in the neck to set up Eclipse in Java.

It’s pretty convenient that I am learning XML because I had to use it recently at my job, and knew where I was because of watching a few videos.

From the blog jamescelona » WSU CS by jamescelona and used with permission of the author. All other rights reserved by the author.

Onto Android

John, Joe, and myself have begun a new project and have said goodbye to Eucalyptus.  We will be designing our own app for the android market.  John had been talking for a while about how he needed a task manager that actually did what he wanted and needed it to do.  No, not a task manager to kill processes etc but one designed to integrate with a calendar, or any other event based program we can use.  We will be designing a ‘normal’ task manager app at first but will be making it very modular because we’re really not sure how difficult the development process will be.  We will add as we need, or if we can, many key features that will actually make the app useful.  By the end we will submit it to Google Play and hope for the best.

The journey begins.

From the blog jamescelona » WSU CS by jamescelona and used with permission of the author. All other rights reserved by the author.

Have been reading design paradigms for Android Apps

Since I really have never owned an Android phone I don’t know much about their apps.  I spent a while today looking at the difference menu styles and how to design to optimize for certain button layouts.  Some phones have more buttons..stuff like that.  As I was browsing this my reddit feed led me to this link: http://www.androiduipatterns.com/2012/06/emerging-ui-pattern-side-navigation.html which talks about the side style menu, such as Facebook. I can only hope our app isn’t as slow as the Facebook one, though.  The article talks about how, “The side navigation replaces the much criticized dashboard pattern in the apps.”  I think it would be a cool implemented on our app.

On a side note, I think I need to find supplemental methods of learning Java/XML the Android way.  I don’t mind the new Boston but sometimes when he talks about stuff in Java that has been burned in my brain for life gets me distracted.

From the blog jamescelona » WSU CS by jamescelona and used with permission of the author. All other rights reserved by the author.

Using Git in Windows

With our GitHub repository ready, and now that my Android development environment has been setup, it was time to install Git so I can actually start working. Git is a Linux tool and all my previous Git experience has only been inside that environment. But luckily Git has been ported to Windows, so I can use Git on my Windows machine without having to run it inside a VM. There are several options for running Git in Windows, and first I chose msysgit, the official Git for Windows project. I then abandoned that in favor of the GitHub application, which promised seamless connection to the GitHub website, including automatic maintenance of SSH keys.

The GitHub app has a nice GUI interface, and seems to be very easy to use. But I honestly haven’t used it much–the app also installs a Git shell, which I vastly prefer to the GUI. The Git shell emulates a Linux terminal, inside a Windows command prompt. Several of Linux commands are emulated inside the shell, such as cp, mv, rm, ls, cd, and others. Tab completion is also implemented which is wonderful. The emulated commands are not as powerful as their real versions (for example, typing “ls” works, but my preferred “ls -lh” doesn’t), but it’s still great to have this option. You can even open text files for editing from within the command prompt– just type notepad instead of nano or gedit. Lastly, a hugely useful addition to this Windows implementation that isn’t even in the Linux original:  the prompt in the shell uses symbols to help you keep track of your added, modified, and removed files, and changes color depending on your commit status!

From the blog Code Your Enthusiasm » WSU CS by Jon and used with permission of the author. All other rights reserved by the author.

Organizing our GitHub repository

Our Android project will have an online repository hosted at GitHub. I’ve never used GitHub, though at work I use a local install of the similar Gitorious service. So far, we don’t have anything in the repo besides a GPL notice. The repository does have an integrated wiki that I have put some work into already. James and I discussed how to organize the repo and we decided we wanted to follow a professional approach that an actual project team working on commercial software might follow. Here is an excellent description of the model we will be using.

Basically, there will be four permanent branches. The first two branches, jon-dev and james-dev, are personal development branches that will hold snapshots of the project as we are working on it. We will keep our individual work separate in these branches so nothing one person does can affect the other. Here we also have the freedom to absolutely break the app while not affecting the snapshots in the next two branches. The code in these branches cannot be guaranteed to  build into a perfect working app, but that is to be expected because this is the entry point for brand new contributions.

The third branch, develop, is where James and I will merge our work from our individual branches after we have gotten our code working the way we want. Snapshots in the develop branch should build into a relatively stable app, similar to nightly builds in a major open source project, though bugs may still be present.

The fourth and final permanent branch, master, is reserved for major releases of the app. Once the code in the develop branch has enough features implemented, and has been tested thoroughly, it can be merged into the master branch and tagged as a milestone build. Apps build from code in the master branch should be considered stable and without major bugs.

We can also create temporary hotfix branches as we need to. For example, if a bug is discovered in the master branch, we can create a branch to fix the bug, merge it back into master after the fix has been tested, and then delete the temporary branch.

From the blog Code Your Enthusiasm » WSU CS by Jon and used with permission of the author. All other rights reserved by the author.

Setting up the Android SDK & Eclipse

This summer I will be developing an Android app with James, who is also a senior CS major at Worcester State. Neither of us have ever done anything like this, so needless to say it will be an adventure. The first thing I had to do was to properly set up my development environment. Google has a guide here, but it wasn’t the smoothest process. There was a bit of trial and error along the way. I have a fairly modern computer running Windows 7 64-bit. Here’s my rundown of setting everything up:

Step one was to install the JDK, Java Development Kit. That was easy enough. Oracle’s website has lots of options, so it was important to choose the standard 32-bit JDK installer. Even though I have a 64-bit system, I chose 32-bit in order to maximize compatibility.

Step two was to install the Android SDK. Once that has been installed, running the SDK Manager lets you choose what Android platforms to download. For now, I only downloaded the latest version, 4.0.3/API15.

Next was to install Eclipse. Eclipse.org has a lot of options. I opted for Eclipse for Java Developers 32-bit (matching my 32-bit JDK), though I hear Eclipse Classic works too. There is no installer exe for Eclipse, only a zip file, which might confuse Windows users. You just need to extract the zip file into your JDK directory, and that’s it. In my case, Eclipse ended up in “C:\Program Files (x86)\Java\jdk1.7.0_04\eclipse”. Then you run eclipse.exe from that folder and off you go.

Inside Eclipse, the next step is to install the ADT plugin, which will integrate several Android tools into Eclipse. This is where things started getting a little hairy. According to the Google guide, Eclipse should be able to grab the tools from a repository located here: “https://dl-ssl.google.com/android/eclipse/”. Eclipse did that, then proceeded to tell me that the tools couldn’t be installed. After a lot of searching, I didn’t find a fix, but I learned the problem possibly has to do with the fact that I am using a newer version of Eclipse (Indigo) than when the guide was written (Helios). Thankfully, Google offers a manual download of the tools here, so I was finally able to get the ADT plugin up and running.

Now that the Android SDK and Eclipse were both configured, it was time to write a program! The Google guide has a very nice-looking series of tutorials, starting with a Hello World app. The first thing to do was to make an AVD (Android Virtual Device), an Android phone emulator. This went smoothly. So did creating the new project, and writing up the simple code. Now to run my very first Android program…

FAIL. In the console, in bright red, I see the message “PANIC: Could not open: C:\Users\Jon\.android/avd/my_avd.ini”. What is this?? Why can’t it find my emulator??? I check, and sure enough, there is no .android folder in my Jon directory. The .android folder is on the root of my D:\ drive, and the AVD is in there. So why is Eclipse looking in my user folder, and how can I fix it? After a lot of searching, I found my answers here. It turns out that this is an ADT bug, and to fix it, I had to make a symbolic link between the two locations. So, in a Windows command prompt, I ran:

mklink /J “C:\Users\Jon\.android” “D:\.android”

An .android folder showed up inside my user directory, identical to the one in D:\. It’s important to note that if I ever want to delete this link, I need to run rmdir rather than just delete the folder. Otherwise, Windows will delete both locations instead of just the symbolic link. I went back to Eclipse and tried running my program again, and it worked! I’ve never been so happy to see “Hello World” appear on my screen.

From the blog Code Your Enthusiasm » WSU CS by Jon and used with permission of the author. All other rights reserved by the author.