Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android

Self-destructing message app: Problems due to differences in Eclipse version (up to stage 3) and Bugs (stage 5,7)

I just finished the self-destructing message app course and I thought I'd share a summary relating to some areas where I got stuck due to 1) differences in my version of Eclipse vs the one in the video and 2) bugs (that Ben eventually discovered but in later videos).

1 Answer

  • My version of Eclipse: 23.0.2.1259578 (up-to-date)
  • SDK installed: up to API 20

S1V4 - Create Project

The following configuration works (as confirmed by several posts on the forum):

1st page of wizard:

  • Min SDK: API 14 (like in the video)
  • Target SDK: API 19
  • Compile SDK: API 20 (the latest and default option).

For Target SDK, "Why not latest API? Android Wear api causes problems since we will be using input text fields: Android Wear is a wrist watch and you cannot type anything in it so you cannot use EditText on 4.4W. Change the API to 19 or less or change it to 4.4L which can be downloaded from SDK Manager. This is not a bug." source: stackoverflow.com/a/24714959

2nd page of wizard:

Uncheck "Create custom launcher icon" just like in the video. For the rest you can also follow the video.

3rd page of wizard (Create Activity):

This page is different from the video. The video version has different and fewer options

  • Ben chose "Blank Activity".
  • I chose "Tabbed Activity"

4th page of wizard (Blank Activity in video, Tabbed Activity for me)

  • The video version doesn't have an input field for "Fragment Layout Name". For this I kept the default fragment_main
  • The video has a "Navigation Type" dropdown list
  • I get instead a "Navigation Style" dropbox. From which I chose "Action Bar Tabs (with ViewPager)"

S2V6 - Logging out

Ben manually creates the onOptionsItemSelected(MenuItem item) method.
In my case, it came with the new project. It's the same code. Just delete it and follow the video. You will see small differences like this often.

S3V2 - How fragments are used

  • ViewPager comes from android-support-v4.jar
  • My project came with android-support-v13.jar.

I don't know if it was necessary but I took the android-support-v4.jar file from the Treehouse's video page > Downloads > Project Files > Ribbit_s2v7.zip and dragged it to the /libs folder in my project. So I had both .jar files.

S3V3 - Modifying Tabs from the template

This is a big one in terms of differences in code. But actually in our advantage! I didn't need to follow the steps in this video, except of course, for the following App Feature related stuff:

  • Set getCount to return 2
  • Change the Tab text from "section 1" and "section 2" to "inbox" and "friends", and delete section 3

S3V4 - Modifying Fragments from the template

This is the one that is discussed in the forums and the teacher notes. I followed their advice and it works.

Basically, after having moved the SectionsPagerAdapter class out of MainActivity.java and into its own file, I did this:

In MainActivity.java, change

public class MainActivity extends Activity implements ActionBar.TabListener {

to

public class MainActivity extends FragmentActivity implements ActionBar.TabListener {

then make sure the imports are in order, as per the teachers notes. Here is a copy-paste of my imports.

//For MainActivity:
import android.app.ActionBar;
import android.app.FragmentTransaction;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.view.ViewPager;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import com.parse.ParseUser;

//For SectionsPagerAdapter:
import java.util.Locale;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.content.Context;

S5V2 - Presenting a list of choices in a dialog

A bug crept in at 02m30s that was not discovered until S8V3. In the switch statement, there should be a break; statement after each case.

S7V3 - Creating a custom list adapter for messages

Bug 1:

The app crashed. It didn't in the video and remained undetected in the videos until Ben spotted it in S8V2. Thanks to Art Lleshi for posting the solution (https://teamtreehouse.com/forum/anyone-else-getting-a-null-pointer-exception-when-loading-the-imageview).

We need to add

convertView.setTag(holder);

at the end of the if (convertView == null) statement.

Bug 2:

In lesson S8V2, Ben improves the MessageAdapter code by fixing a cosmetic bug. Thought I'd mention it since its related to the work we're doing in S7V3.

S8V2 - Maintaining scroll position in a listview

See notes for S7V3

S8V3 - Deleting the whole message

See notes for S5V2