Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Android Build a Simple Android App with Kotlin Testing and Debugging Writing to the Log

Enyang Mercy
PLUS
Enyang Mercy
Courses Plus Student 2,339 Points

Android log class name...simpleName

Part 2 seems difficult. Just did Part one successfully but part2 has an error. A simpleName method has been used as instructed instead of hard-coding to get the class name. Error: make sure you're using the class name/type mismatch

TreehouseActivity.kt
import android.app.Activity
import android.os.Bundle

class TreehouseActivity : Activity() {
  val TAG = TreehouseActivity:: class.java.simpleName

  override fun onCreate(savedInstanceState: Bundle) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_treehouse)
    Log.d(TAG, "Activity created!")

  }
}

2 Answers

Hi there,

Your code passed the challenge for me but the challenge seems to be having intermittent problems. I had to try a few times before it went through OK.

Steve.

val TAG = TreehouseActivity::class.java.simpleName
Enyang Mercy
PLUS
Enyang Mercy
Courses Plus Student 2,339 Points

Thanks Steve. I don't know why kotlin keep having errors. I would have chosen java rather than kotlin.