Reputation: 3402
I am running my application in nexus 7 with api 21.When app opens from background it force close with following exception
java.lang.UnsupportedOperationException: Can't convert to color: type=0x1
at android.content.res.TypedArray.getColor(TypedArray.java:404)
Log cat
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.online.Androidv2/com.online.Androidv2.PagerActivity}: java.lang.UnsupportedOperationException: Can't convert to color: type=0x1
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: java.lang.UnsupportedOperationException: Can't convert to color: type=0x1
at android.content.res.TypedArray.getColor(TypedArray.java:404)
at android.app.Activity.onApplyThemeResource(Activity.java:3674)
at android.view.ContextThemeWrapper.initializeTheme(ContextThemeWrapper.java:140)
at android.view.ContextThemeWrapper.setTheme(ContextThemeWrapper.java:85)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2244)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
I am using the theme AppTheme for the application.
<style name="AppTheme" parent="AppTheme.Base" />
<style name="AppTheme.Base" parent="Theme.AppCompat">
<item name="colorPrimary">@color/theme_color</item>
<item name="colorPrimaryDark">@color/theme_color_dark</item>
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
</style>
<style name="DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">
<item name="spinBars">true</item>
<item name="color">@android:color/white</item>
</style>
Color values is
<color name="theme_color">#b61702</color>
<color name="theme_color_dark">#a70001</color>
I can't find the reason for this.Any help?
Upvotes: 1
Views: 6838
Reputation: 466
I encountered same problem, After I check my code, I found I used @style/custom to set android:textColor in my style xml file. Then I just refer @color/custom to android:textColor, error disappeared.
And error happened in Android API 18, API 23 works well.
useful link: java.lang.UnsupportedOperationException: Can't convert to color: type=0x1
Upvotes: 1