Posts tagged: android

NoClassDefFoundError After ADT Update

I’ve just returned to an Android project after a couple of months’ pause. After updating Eclipse and ADT, my project started throwing an exception:

06-12 21:45:26.154: ERROR/AndroidRuntime(3654): java.lang.NoClassDefFoundError: com.google.gson.gson

This JAR file was clearly in my “lib” folder in the project and in my build path. After entirely too much fiddling about, cleaning, rebuilding, and googling, I discovered my problem. Apparently, ANT is now expecting these to be in the “libs” folder. After moving all of my third party JAR files from “lib” to “libs”, deleting “lib”, and restarting Eclipse, all is right the the world again!

Using simple_list_item_2 with an ArrayAdapter (Android)

Today I wanted to display static a ListView of properties and their values. It’s Friday, so I really wanted to do this with as little work as possible. Android’s free layout simple_list_item_2 sounded like what I wanted, but it wasn’t immediately clear how to handle this. There are a lot of lazy ways we can list single values, but Googling around how to use simple_list_item_2 resulted in lots of questions with no real answer.

I found Mark Assad, who parsed the system layout files into raw XML. The led to the magic answer of TwoLineListItem widget. Finding this widget allowed me to write a simple ArrayAdapter of key/value pairs.

adapter = new ArrayAdapter(this,android.R.layout.simple_list_item_2,list){
        @Override
        public View getView(int position, View convertView, ViewGroup parent){
            TwoLineListItem row;
            if(convertView == null){
                LayoutInflater inflater = (LayoutInflater)getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                row = (TwoLineListItem)inflater.inflate(android.R.layout.simple_list_item_2, null);
            }else{
                row = (TwoLineListItem)convertView;
            }
            BasicNameValuePair data = list.get(position);
            row.getText1().setText(data.getName());
            row.getText2().setText(data.getValue());

            return row;
        }
    };
listView.setAdapter(adapter);

Hope this saves someone else some time, as I spent an embarrassing amount of time determined to use the simple_list_item_2 layout.

I want to be an App Store Millionaire, Who’s With Me?

My envy is becoming unbearable. I’m not sure how much more I can take of these mobile app success stories. People are making hundreds and thousands of dollars per month with their relatively simple apps. There’s a gold rush on the mobile frontier, and I’m just now learning how to use a pickaxe.

Honestly, I’d be happy just to have a product on an app store and receive a check for 99¢. One sale, and I’d feel like I’ve accomplished something. I don’t need to make millions of dollars like the guys that made Doodle Jump for the iPhone.

I’ve got a summer without classes. I’m determined to publish something either on the Android app store or maybe an XNA project. A simple gaming project is the most interesting to me, but a lack of artistic direction is always my biggest roadblock. Anyone interested in a little collaboration? I mean, look at Doodle Jump. We can do that!