Notice
Recent Posts
Recent Comments
Link
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
Tags
more
Archives
Today
Total
관리 메뉴

느릿느릿 프로그래밍

[Android] 안드로이드 렌더링 문제/레이아웃 design, preview가 특별한 에러 없이 안 보일 때 / The following classes could not be instantiated: - android.support.v7.widget.ActionBarContainer (Open Class, Show Exception, Clear Cache.. 본문

프로그래밍/Android

[Android] 안드로이드 렌더링 문제/레이아웃 design, preview가 특별한 에러 없이 안 보일 때 / The following classes could not be instantiated: - android.support.v7.widget.ActionBarContainer (Open Class, Show Exception, Clear Cache..

김슈달 2018. 7. 4. 14:10
반응형

targetSdkVersion이 28인 어플 작업을 하는데

이 프로젝트의 경우 처음부터 design/preview가 제대로 동작하지 않았다.

그러나 특별한 빌드 에러는 없었고, 애뮬이나 폰에 실행하면 레이아웃이 제대로 나오면서 잘 동작했다.


그래서 오늘 이 문제를 해결하기 위해 찾아보던 방법들은 다음과 같았다.


1. sdk 낮추기



저 빨간색 동그라미에서 sdk 버전을 하나씩 낮추면서 잘 나오는 버전이 있나 확인해보는 것이었다.

그러나 내 경우에는 되지 않았다.


2. build.gradle(Module.app)의 sdk 버전 낮추기


최소 sdk를 23에서 25로 올리고, 최대를 27로 낮춰보았으나 역시 되지 않았다.



이 외에도 다양한 방법들을 시도하였으나 특별히 되는 것이 없다가,

문득 preview에서 에러를 찾았다.



(지금은 해결해서 회색이지만) 저 느낌표 아이콘이 빨간색임을 보고 눌러보니 아래와 같은 에러가 있음을 확인할 수 있었다.


1
2
3
4
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)
cs


*해결

최종적으로는 app\res\values\styles.xml을 수정함으로써 문제를 해결하고 정상적인 preview 화면을 볼 수 있었다.

1
2
    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
cs


의 parent를 아래 처럼 바꾼다.


1
2
    <!-- Base application theme. -->
    <style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
cs


참고
https://stackoverflow.com/questions/45863790/the-following-classes-could-not-be-instantiated-android-support-v7-widget-appcom/45881066


반응형
Comments