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?

More than 3 years have passed since last update.

AndroidでFragmentを実装するとRunTimeExceptionが発生する

Posted at

#概要
Fragmentを実装しようとするとjava.lang.RuntimeException: Unable to start activity ComponentInfo{}~といったエラーが発生する。
日本語でいい対処法の記事がなかったので備忘録替わりに。

#エラー内容
Fragmentを実装すると

java.lang.RuntimeException: Unable to start activity ComponentInfo{}~

といったエラーが出てくる。
ついでに以下のような原因も記載される

Caused by: android.view.InflateException: Binary XML file line #6: Binary XML file line #6: Error inflating class fragment
     Caused by: android.view.InflateException: Binary XML file line #6: Error inflating class fragment
     Caused by: java.lang.IllegalArgumentException: Binary XML file line #6: Must specify unique android:id, android:tag, or have a parent with an id for com.websarva.wings.android.fragmentsample.MenuListFragment

#解決方法
エラー内容のCaused byでidが必要と言われていたのでひとまずactivity_main.xlmのタグ内に任意のidをつける。
(例;android:id="@+id/fragmentSample")
nameだけはつけていたのだが、idも別で用意する。
すると正常に動いた。

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?