ENAN

Developer, Artist, Traveler

공부/Android

안드로이드 스튜디오에서 레이아웃 프리뷰가 보이지 않을 때

ENAN 2018. 7. 2. 13:10


안드로이드 스튜디오에서 레이아웃 프리뷰가 보이지 않는 문제 해결법

(android studio version 3.1.3 기준)



안드로이드 스튜디오 3.1.3 버젼에서 프로젝트를 만들면 레이아웃이 안보이는 문제가 생긴다.

왜인지는 모르겠으나 안드로이드 스튜디오가 업데이트 되면서 appcompat-v7 최신버젼에서 생기는 버그인 것 같다고 한다.


참조한 원문 링크 : http://kiwinote.tistory.com/147


구글링 해 본 결과 위 링크에서 해답을 찾았다.


아래는 텍스트뷰가 안보이는 모습


에러창을 보면 아래와 같은 에러가 떠있다.


Render problem : Failed to load AppCompat ActionBar with unknown error.


Failed to instantiate one or more classes :

The following classes could not be instantiated:

- android.support.v7.widget.ActionBarContainer (Open Class, Show Exception, Clear Cache)

- android.support.v7.widget.ActionBarContextView (Open Class, Show Exception, Clear Cache)

- android.support.v7.app.WindowDecorActionBar (Open Class, Show Exception, Clear Cache)

 Tip: Use View.isInEditMode() in your custom views to skip code or show sample data when shown in the IDE.  If this is an unexpected error you can also try to build the project, then manually refresh the layout.  Exception Details java.lang.ClassNotFoundException: android.view.View$OnUnhandledKeyEventListener Copy stack to clipboard



해결책은 gradle 파일을 수정하는 것이다.

아래의 사진처럼 dependencies에서 alpha3을 alpha1로 수정한다.



그러면 위쪽에 그래들 파일이 수정되었으니 sync해야 잘 작동한다는 메세지가 뜬다.

오른쪽에 있는 Sync Now를 누르자.



이제 잘 보인다!



'공부 > Android' 카테고리의 다른 글

[Android] AAC - LiveData  (0) 2021.03.12
Realm vs Room  (0) 2021.02.28
[Android] AAC - Room  (0) 2021.02.02
Coroutine과 Retrofit 함께 활용하기 -2) 레트로핏 편  (2) 2020.06.13
Coroutine과 Retrofit 함께 활용하기 -1) 코루틴 편  (0) 2020.06.03