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


A couple of issues with "Shaking Things Up"


In the 'Running An App On A Device' quiz, the question:

Fill in the blanks with either "does" or "does not": Connecting a device to Windows [ ] require special drivers, connecting to a Mac [ ] .

Is not returning any correct answers. I've attempted every combination of the answer and nothing is correct, really?

does, does does, does not does not, does does not, does not

In the video, Ben states that you may simply connect the USB cable from the laptop to the device or in some instances you may have to download drivers specific to your device.


In the video 'Adding a Shake Detector' there is no '@Override' annotation over 'private void onShake();

However in the video 'Activity Lifecycle', the '@Override' is there. In effect I went back to my Eclipse and added the annotation yet I get an error stating the method onShake must override superclass method to the effect that I'm unable to run the app until the error is fixed. I remove the annotation and attempt to run the app on my device(Galaxy S III) and the app does not work properly. It loads but does nothing when shaken - I even tried stirring. Could this be the reason the app is not working properly? I have not deviated (added or removed code) from any steps in the videos.

Please help :-( (yes, i'm pouting on both counts)

14 Answers

Ben Jakuben
Ben Jakuben
Treehouse Teacher

Hi Nicole,

Sorry about your trouble! Thanks for pointing out the error in the quiz...there's a bug (and workaround) in fill-in-the-blank questions with multiple answers. I fixed the question using the workaround.

As for the @Override problem, that usually occurs when project settings get set to an older version of Java. This can happen when importing a project into Eclipse, among other reasons.

Try the following solution and let us know if it works or not. In Eclipse, right-click on the Crystal Ball project in Package Explorer and select Properties at the bottom. Click on Java Compiler on the left side and then uncheck "Enable project specific settings" (if it is checked). Then click on the "Configure Workspace Settings" link in the upper-right and set "Compiler Compliance Level" to 1.6.

The @Override annotation was introduced in Java 1.6 (or Java 6 as it's often called). Either I forgot to check settings when I created and uploaded project files, or there might be some other bug in Eclipse. I'll review the project files and see if there's anything I need to change.

Hope this helps!

Thanks Ben, you're awesome! Well, the error for the annotation is no longer showing but the app is still not performing. This is from the LogCat, there are three error lines, one for the 'trace file' and two for a ReadConfigFile.

12-14 01:53:07.822: D/dalvikvm(30315): Late-enabling CheckJNI 12-14 01:53:08.072: E/Trace(30315): error opening trace file: No such file or directory (2) 12-14 01:53:08.072: D/ActivityThread(30315): setTargetHeapUtilization:0.25 12-14 01:53:08.072: D/ActivityThread(30315): setTargetHeapIdealFree:8388608 12-14 01:53:08.072: D/ActivityThread(30315): setTargetHeapConcurrentStart:2097152 12-14 01:53:08.643: D/libEGL(30315): loaded /system/lib/egl/libEGL_adreno200.so 12-14 01:53:08.643: D/libEGL(30315): loaded /system/lib/egl/libGLESv1_CM_adreno200.so 12-14 01:53:08.663: D/libEGL(30315): loaded /system/lib/egl/libGLESv2_adreno200.so 12-14 01:53:08.803: I/Adreno200-EGLSUB(30315): <ConfigWindowMatch:2087>: Format RGBA_8888. 12-14 01:53:08.863: E/(30315): <s3dReadConfigFile:75>: Can't open file for reading 12-14 01:53:08.873: E/(30315): <s3dReadConfigFile:75>: Can't open file for reading 12-14 01:53:08.873: D/OpenGLRenderer(30315): Enabling debug mode 0

I have tried a few things. One was creating a 'trace file' which was fun but did not allow the app to work properly. Another was reviewing the code in the ShakeDetector file to possibly capture an error. I went over the code I created using the videos and I didn't see any errors there that would prevent a response from the sensor manager. i also checked the settings on my phone to make sure motion detection is enabled.

I don't know what else to do.

Ben Jakuben
Ben Jakuben
Treehouse Teacher

I'm sorry you're having so much trouble! I won't have time to look into this personally for another day or two because of travel, but I'll take a look when I can.

One thing you could try would be to download Google's new Android bundle from http://developer.android.com/sdk. It's very similar to ours. You could import your project into that version of Eclipse (both are very similar). I walk through setting up the Google bundle in Stage 1 of the new Blog Reader project if you have questions about it.

Still nothing. I don't have enough knowledge to analyze the issue, it may be with my phone although the sensor manager seems to working fine with other 'shake it' apps.

I'm going to move forward and hopefully the end result will be more successful.

Question: In the verbose method of the log class, I see a tag for 'unregisterListener' when I close the app from my mobile device but I don't see a 'registerListenr' tag when the app is loaded to my mobile device . When I click play from Eclipse and the app loads on my mobile device, should there be a tag for 'registerListener' ?

Ben Jakuben
Ben Jakuben
Treehouse Teacher

I looked at both of these a little tonight but don't have any answers yet. Hopefully I'll have more time tomorrow to follow up. In the mean time, you can definitely continue with the videos (and the next project) and get everything in place

I do appreciate your time, Ben.

Today, I went through the Debugging: Troubleshooting Line By Line stage. After completion I did some things on my own. I hovered over 'Activity' and then opened the declaration which reads 'Class File Editor Source Not Found'. Although I"m not yet well versed this seems like a major issue in the way the app runs.

The line reads The JAR file C:\Users\SweetNici\Videos\Treehouse\Videos\Android\android_dev_environment_windows_64bit\android-sdk-windows\platforms\android-16 has no source attachment.

Then there is a button to Attach Source.

Could this be the cause?

Just going through each class while in Debug perspective I see that there is no source attachment for any of the classes listed below:

  • import android.app.Activity;
  • import android.graphics.drawable.AnimationDrawable;
  • import android.hardware.Sensor;
  • import android.hardware.SensorManager;
  • import android.media.MediaPlayer;
  • import android.media.MediaPlayer.OnCompletionListener;
  • import android.os.Bundle;
  • import android.util.Log;
  • import android.view.Menu;
  • import android.view.animation.AlphaAnimation;
  • import android.widget.ImageView;
  • import android.widget.TextView;

The class listed below does show the source code in declaration view, I can assume this means there is a source attachment.

  • import com.example.crystal.ball.ShakeDetector.OnShakeListener;
Ben Jakuben
Ben Jakuben
Treehouse Teacher

Hi Nicole,

I'll try to answer all the open questions in this thread! I'm on vacation and only have time to do in-depth research after my kids have gone to bed. :) Anyhow...

First of all, I can't seem to find any information about the errors for "opening trace file" and "s3dReadConfigFile". They may not be related to your problems with the app at all, though I just can't reproduce on my own Galaxy S3 or find much info online. Let's table this for a moment.

About the register/unregister question...in your LogCat view, what are the values in the "Application" and "Tag" when you see the 'unregisterListener' message? I can't recreate this, and there doesn't necessarily need to be matching events in the log...it totally depends on what you (or whatever developer) decide to output to the log.

I wonder if your onPause() and onResume() methods are being called? Add the following Toast messages in each to confirm if they're being called or not. onPause() and onResume() should also have that @Override annotation before them, and if that was giving you problems before, I wonder if it's all related.

Toast.makeText(this, "I'm in the onPause() method!", Toast.LENGTH_LONG).show();

Toast.makeText(this, "I'm in the onResume() method!", Toast.LENGTH_LONG).show();

As for the "no source attachment"...that's because source code for Android system classes isn't provided or attached by default. Our own code is present by default, which is why you can step into the ShakeDetector.java file for debugging. You don't need the Android source code to debug (I usually just skip the Android classes), but it's fairly simple to attach if you want. Here's a post about it: http://stackoverflow.com/a/11493625/475217

Anyhow, let me know if onPause() and onResume() are being called and then we can hopefully pick up from there.

Also, if you'd like, zip up your project and email help@teamtreehouse.com so we can track it through our support system, too.

Those methods are being called.

The .zip option sounds like a winner!

*About the register/unregister question...in your LogCat view, what are the values in the "Application" and "Tag" when you see the 'unregisterListener' message? *

com.example.crystal.ball and SensorManager.

I sent a .zip to the support team.

Your time on this is appreciated, you're awesome! Enjoy your vacation!


Ben Jakuben
Ben Jakuben
Treehouse Teacher

Ah ha! Found the error. It was a hard one to track down! I had to resort to comparing with my own working code. Things looked mostly good in the debugger, but the code in the ShakeDetector class wasn't being called. So I knew something wasn't quite right with how the ShakeDetector was being set up.

Anyhow, I found it quickly after starting to compare code line by line with mine. Here's the problem:

Your code:

public class MainActivity extends Activity {

    private static final int TYPE_ACCELEROMETER = 0;

    // Excluding working code...

    public void onCreate(Bundle savedInstanceState) {
        // Excluding working code...        
        mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
        mAccelerometer = mSensorManager.getDefaultSensor(TYPE_ACCELEROMETER);

This last line should read:

mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);

Make this change and delete the line at the top where you declare TYPE_ACCELEROMETER (maybe you were trying to fix an error you were receiving?). Making those changes allowed it to work for me.

Hooray! I can't believe I missed that knowing how many times I looked at the SensorManager overview on the developer.android website. Quite embarrassing.

I see that I was way out in left field in my analyzation path; thank you so much for your patience with me!