1
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?

【Androidアプリ開発】Hilt Unable to instantiate activity 解決策

Last updated at Posted at 2024-10-28

はじめに

DIをやりたかったのでHiltを使うことにしました。

gradleとか設定してビルトできた。

が、、

アプリ開くと

Unable to instantiate activity ComponentInfo{省略}: java.lang.ClassCastException:
アプリ cannot be cast to android.app.Activity

時間かかりました。

解決策

activiryのandroid:nameにhiltのアプリケーションを入れてしまっていた

  <application
      //ここが正解
      android:name=".AwesomeApp">
        <activity
        //ここのnameにApp入れていた
            android:name=".MainActivity"

似てるやん

まさかすごいケアレスミス
サイトの説明に沿ってミスらないようにしよう笑

参考資料

リンク1

1
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
1
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?