Android Studio Error: String literal in setText cannot be translated

String literal in setText cannot be translated

This is not an error and you can safely ignore it (unless you need translation in your app).

It is simply a notification by Android Studio that you should be using a string resource file instead of a hard-coded string.


If I had to guess at the source of the issue since you did not post the logcat, it is this.

You can't use findViewById before setContentView because there is no view to "find".

Please try something like the following code

public class MainActivity extends AppCompatActivity {

    private TextView outputBottom;    

    protected void onCreate(Bundle b) {
        super.onCreate(b);
        setContentView(R.layout.activity_main);
        outputBottom = (TextView)findViewById(R.id.output);
    }

There are two issues here. First, you can't use findViewById until you have "created" things and have a view to find things with, so as the previous answer you want to separate them.

public class MainActivity extends AppCompatActivity {

  private TextView outputBottom;    

  protected void onCreate(Bundle b) {
      super.onCreate(b);
      setContentView(R.layout.activity_main);
      outputBottom = (TextView)findViewById(R.id.output);
  }

  ...
}

To set text, it's better not to "hardcode" with a string in quotes, but to create a string file and ask for it, which will look more like this:

outputBottom.setText(R.string.my_words);

Here are the developer notes on strings.

If you're using Android Studio there are tutorials for how to make that happen.