0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

エラー「Cannot resolve symbol 'ActivityMainBinding'」の解決法

Posted at

開発環境

  • Android Studio Narwhal 4 Feature Drop | 2025.1
  • 言語:Java
  • ViewBinding:使用
  • Gradle Plugin:8.13.0
  • Gradle Version:8.13

エラー内容

private ActivityMainBinding _activityMainBinding;

上記コードで次のようなエラーが発生。

Cannot resolve symbol 'ActivityMainBinding'

解決

1.メニューバーの像のマークをクリック
 →「Sync Project with Gradle Files」を実行
image.png

2.同期が完了すると、ActivityMainBindingが認識されるようになる

考えられるいくつかの原因

1.ViewBindingが有効になっていない
→app/build.gradle の android ブロック内に以下があるか確認。

android {
    ...
    buildFeatures {
        viewBinding true
    }
}

2.レイアウトファイル名の不一致
3.import文が正しくない
4.変更がGradleに反映されていない(今回の私の場合)

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?