Android Studio activity 未链接

Android Studio activity not linking

我正在 Android Studio 中为我的应用制作登录屏幕。

我的 MainActivity.java:

里有这个
Intent intent = new Intent(MainActivity.this, NewAccountActivity.class);
startActivity(intent);


这在我的 NewAccountActivity.java:

public class NewAccountActivity extends AppCompatActivity {

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_new_account);
  }
}


还有我的 activity_new_account.xml:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Test"
        android:textSize="24sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>


但是......它给了我一个来自NewAccountActivity.java的错误:Cannot resolve symbol 'activity_new_account'


有谁知道如何解决这个问题,我已经用谷歌搜索了半个小时,但仍然没有得到答案。

最近一次更新后,您经常遇到这种错误。 为了解决问题,请尝试执行以下步骤(对我有用):

点击菜单中的文件

点击无效caches/restart

现在,等待 android 工作室重新启动并重建。

之后你的问题应该就解决了