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 trialNikki Wong
9,066 PointsLog.d(tag, msg)?? Why am I getting errors?
in my own android studio it removes the tag id automatically when I used TAG :
Log.d( TAG, "We're logging from the onCreate() method");
but here I tried: Log.d( tag: TAG, "We're logging from the onCreate() method");
as well as:
Log.d( TAG, "We're logging from the onCreate() method");
and I kept getting errors? Help?
package com.teamtreehouse;
public class TreehouseActivity extends Activity {
public static final String TAG = "TreehouseActivity";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_treehouse);
Log.d(tag: TAG, msg: "Activity created!");
}
}
2 Answers
Seth Kroger
56,414 PointsIf you are trying to mimic what you see in Android Studio, you should know that the "tag:" and "msg:" are not part of the code you write. Notice how they are highlighted and in a different font in AS. They are also not editable. It's additional guidance from AS telling you what arguments the method expects. You do not type them in yourself and don't appear in your code outside of AS.
Nikki Wong
9,066 PointsThanks Seth!! I know that, but I don't know how to write it for the challenge as they don't automatically pop up when I type Log.d ?
Seth Kroger
56,414 PointsLog.d(TAG, "Activity created!");
Just the two values separated by a comma.
Nikki Wong
9,066 PointsThanks a mil Seth! Was a bit confusing for a beginner using Android Studio
Nikki Wong
9,066 PointsThese are the errors I keep getting?
./com/teamtreehouse/TreehouseActivity.java:11: error: ')' expected Log.d(TAG, msg:"Activity created!"); ^ ./com/teamtreehouse/TreehouseActivity.java:11: error: not a statement Log.d(TAG, msg:"Activity created!"); ^ ./com/teamtreehouse/TreehouseActivity.java:11: error: ';' expected Log.d(TAG, msg:"Activity created!"); ^ ./com/teamtreehouse/TreehouseActivity.java:11: error: cannot find symbol Log.d(TAG, msg:"Activity created!"); ^ symbol: variable msg location: class TreehouseActivity 4 errors
Burhanuddin Shabbir
4,741 PointsBurhanuddin Shabbir
4,741 PointsPlease try this : Log.d(TAG, msg:"Activity created!");