hotate-issimoの日記

超絶マイペースに自己研鑽に励む

Android開発お勉強

はじめてのAndroidプログラミング第5版やってて躓いたところメモ
進捗はCHAPTER09まで終わったところ

環境:Android Studio 4.2.1

Unresolved reference: が出たらactivity_main.xmlを確認

UI作成時、ビューに付けるidを間違えてないか?

フラグメントを使うときはAndroidManifest.xmlの編集が必要

CHAPTER07から登場
こんな感じのエラーが出たら、

Manifest merger failed : Apps targeting Android 12 and higher are required to specify an explicit value for android:exported when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.

app/manifests/AndroidManifest.xml を開いて、
f:id:hotate-issimo:20220211171232p:plain

<activity>タグのところに
f:id:hotate-issimo:20220211171412p:plain

android:exported="true" を追加
f:id:hotate-issimo:20220211171437p:plain

android:exported が何者なのかは公式リファレンスを参照。
あまり理解できてないけど、テキスト通りにやってるうちはインテントフィルタ(<intent-filter/>)が
あるから、深く考えずに android:exported="true" を追加しておけば問題なさそう。