티스토리 뷰

728x90
반응형

Android material 1.1.0에서 추가된 기능을 사용하고 싶었다.

그래서, 1.0.0 라이브러리를 1.1.0으로 변경한 뒤 빌드를 하니 아래와 같은 메시지가 떴다.

 

2019-11-17 06:10:56.975 12646-12646/com.example.xxxx E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.xxxx, PID: 12646
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.xxxx/com.example.xxxx.views.MainActivity}: android.view.InflateException: Binary XML file line #29: Binary XML file line #29: Error inflating class com.google.android.material.textfield.TextInputLayout
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2857)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2935)
        at android.app.ActivityThread.-wrap11(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1627)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:175)
        at android.app.ActivityThread.main(ActivityThread.java:6724)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:810)
     Caused by: android.view.InflateException: Binary XML file line #29: Binary XML file line #29: Error inflating class com.google.android.material.textfield.TextInputLayout
     Caused by: android.view.InflateException: Binary XML file line #29: Error inflating class com.google.android.material.textfield.TextInputLayout
     Caused by: java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Constructor.newInstance0(Native Method)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:334)
        at android.view.LayoutInflater.createView(LayoutInflater.java:647)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:863)
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:866)
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
        at androidx.databinding.DataBindingUtil.inflate(DataBindingUtil.java:126)
        at androidx.databinding.DataBindingUtil.inflate(DataBindingUtil.java:95)
        at com.example.xxxx.views.login.LoginFragment.onCreateView(LoginFragment.kt:33)
        at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2600)
        at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:881)
        at androidx.fragment.app.FragmentManagerImpl.addAddedFragments(FragmentManagerImpl.java:2100)
        at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManagerImpl.java:1874)
        at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManagerImpl.java:1830)
        at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManagerImpl.java:1727)
        at androidx.fragment.app.FragmentManagerImpl.dispatchStateChange(FragmentManagerImpl.java:2663)
        at androidx.fragment.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManagerImpl.java:2613)
        at androidx.fragment.app.Fragment.performActivityCreated(Fragment.java:2624)
        at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:904)
        at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManagerImpl.java:1238)
        at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1303)
        at androidx.fragment.app.FragmentManagerImpl.dispatchStateChange(FragmentManagerImpl.java:2659)
        at androidx.fragment.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManagerImpl.java:2613)
        at androidx.fragment.app.FragmentController.dispatchActivityCreated(FragmentController.java:246)
        at androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:542)
        at androidx.appcompat.app.AppCompatActivity.onStart(AppCompatActivity.java:201)
2019-11-17 06:10:56.979 12646-12646/com.example.xxxx E/AndroidRuntime:     at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1335)
        at android.app.Activity.performStart(Activity.java:7048)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2820)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2935)
        at android.app.ActivityThread.-wrap11(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1627)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:175)
        at android.app.ActivityThread.main(ActivityThread.java:6724)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:810)
     Caused by: java.lang.IllegalArgumentException: The style on this component requires your app theme to be Theme.MaterialComponents (or a descendant).
        at com.google.android.material.internal.ThemeEnforcement.checkTheme(ThemeEnforcement.java:248)
        at com.google.android.material.internal.ThemeEnforcement.checkMaterialTheme(ThemeEnforcement.java:222)
        at com.google.android.material.internal.ThemeEnforcement.checkCompatibleTheme(ThemeEnforcement.java:150)
        at com.google.android.material.internal.ThemeEnforcement.obtainTintedStyledAttributes(ThemeEnforcement.java:120)
        at com.google.android.material.textfield.TextInputLayout.<init>(TextInputLayout.java:424)
        at com.google.android.material.textfield.TextInputLayout.<init>(TextInputLayout.java:396)
        	... 43 more

 

1.1.0으로 migration 할 때 주의할 점에 대한 글을 찾아봤는데, 못 찾았다.

결국 위 로그에서 가장 중요한 것은 

The style on this component requires your app theme to be Theme.MaterialComponents

위 로그였다.

아래 글에 보면 Change your app theme to inherit from a Material Components theme 라고 적혀 있다.

https://material.io/develop/android/docs/getting-started/

 

Getting Started - Material Components for Android

Getting started with Material Components for Android 1. Depend on our library Material Components for Android is available through Google’s Maven Repository. To use it: Open the build.gradle file for your application. Make sure that the repositories sectio

material.io

그래서, 앱 테마 상속을 AppCompat에서 받던것을, MaterialComponents에서 받게 했다.

 

before

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

 

After

<style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

 

위와 같이 수정하니 정상 동작 했다.

 

 

728x90
반응형
댓글