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 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.