Help with Android studio

Does anyone know how to get the view of the code under activity_main.xml? I’m following a lesson, but the lesson uses an older version which looks different.




Having an issue here with Log.i(tag: “Demo”) msg: “the button was pressed!”);

Tag is staying red. I had the same problem with msg also… “invalidate caches and restart” fixed it… but I can’t get tag to work. It says "cannot resolve symbol ‘tag’.

Any suggestions?

Are you programming in Java or Kotlin?

The usual convention for TAG when writing Java code for Android is to defined TAG as a static final string at the top of your class and set it to the name of the class. I usually do something like this:

public class LockButton extends AppCompatImageButton {
    private static final String TAG = LockButton.class.getSimpleName();


The you can use Log as follows:

Log.i(TAG, "Hello World!);


I’ve just noticed your code:

Log.i(tag: “Demo”) msg: “the button was pressed!”);

Is that the exact code? Because you have an extra closing bracket.

Log.i(tag: “Demo”, msg: “the button was pressed!”);

This should work.

This tutorial is Android Studio “MainActivity_java”

I just edited my post, looks like you have a closing bracket after “Demo” where it should be a comma.


Log.i(tag: “Demo”, msg: “the button was pressed!”);

oops… I should have removed that before I uploaded… I was trying to see if I could find out why it was not accepting it. Even with that removed it still does it.

There should be a comma after “Demo” and before msg

Like this:

Log.i(tag: “Demo”, msg: “the button was pressed!”);

Does this look normal? The tutorial shows that tag: and msg: should be in white.

Ah, I think I know what it is. Did you type in “tag:” and “msg:” yourself? Because those are just syntax highlighting hints that Android Studio adds, you are not supposed to enter them.

still not working bro.:expressionless:

This is closed as it is outside the revived thread guidelines. Feel free to create a fresh topic, or PM one of the Leaders if you think this was incorrectly closed. See here for more info.