안드로이드 스튜디오에서 플젝 생성시 empty Activitiy 가 아닌 다른 유형의 액티비티를 선택시 layout 오류가 발생할 수가 있다.

 

 

The following classes could not be instantiated:
- android.support.design.widget.CoordinatorLayout (Open Class, Show Exception, Clear Cache)
- android.support.design.widget.AppBarLayout (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 의 환경설정 컴파일 문제인걸로 보여진다.
일단, 편법(?)으로 보여지기는 하는데 build.gradle에 아래처럼 추가하면 해결이 되기는한다.

 

configurations.all {
          resolutionStrategy.eachDependency { DependencyResolveDetails details ->
                    def requested = details.requested
                    if (requested.group == "com.android.support") {
                            if (!requested.name.startsWith("multidex")) {
                                      details.useVersion "26.+"
                               }
                        }
                }
        }

또 다른 방법은 추후에 공부하면서 찾아봐야겠다.

+) 렌더링문제는 캐시를 비우고 재시작하면 된다고 하던데 본인은 그렇게 해결이 되지는 않았다.

 

+ Recent posts