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 Build a Simple Android App with Java Testing and Debugging The Android Log

Silas Grygier
Silas Grygier
530 Points

My log's arent working

Hey there! I followed the steps of the video tutorial but my logs aren't being displayed in the logcat. There's a line just above the logcat that indicates that my emulator is disconnected and I'm guessing that thats the reason behind the problem, however my emulator works normal when I run the program.

3 Answers

Seth Kroger
Seth Kroger
56,414 Points

You might need to close and restart the emulator to reattach it. Otherwise there will be no way to see the logs.

Abdalmassih Stity
Abdalmassih Stity
5,987 Points

Log.d( TAG, "Activity created!"); don't include tag: or msg:, they appear after you press enter but you are not supposed to type them.

Ben Schreiber
Ben Schreiber
1,273 Points

Can someone please tell me what am I doing wrong in task1?

Log.d (TAG, msg:"Activity created!");

Is not working.

???

Kareem Jeiroudi
Kareem Jeiroudi
14,984 Points

I noticed the same issue. It wasn't working with me either, and that's probably because we both tried to import the class Log, right? In case you did so, just remove the import and then it should work - although it doesn't make sense, I know. Usually, they remind you to import the class here at Treehouse, but because they didn't this time, and the exercise wasn't working every time I pressed on 'check work', I noticed that there's something wrong with this exercise.

package com.teamtreehouse;

// comment this line and it should be fine
//import android.util.Log;

public class TreehouseActivity extends Activity {

  public static final String TAG = TreehouseActivity.class.getSimpleName();

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_treehouse);

    Log.d(TAG, "Activity created!");
  }
}

If it's still not working just refresh the page and retry and it should eventually work ?.

One last thing: I hope you're not typing msg: passing an argument. I mean like this;

Log.d (TAG, msg:"Activity created!");

Cause this just IntelliJ's hint on what parameter should be passed here and in which order, but you certainly shouldn't be typing the name of the parameter.

// Right!
Log.d (TAG, "Activity created!");