본문 바로가기

Android

cannot find symbol 오류

컴파일 도중 Error:(18, 54) error: cannot find symbol variable toolbar가 발생했다.

cannot find symbol 메시지는 클래스명이나 변수명이 잘못 되었을 경우 컴파일시 에러가 발생한다.


해결방법

=> 1. 철자를 확인한다.

   2. 라이브러리 링크를 확인한다. ( import, classpath )


나는 activity_main.xml 파일에 

<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" />

를 추가했더니 된다.