5.1 Crash - A TaskDescription's primary color should be opaque

后端 未结 4 2046
礼貌的吻别
礼貌的吻别 2020-11-29 05:26

I have implemented material design into my app and it runs perfectly fine on < Android 5 but when I try to run on Android 5.0 and above I get the following in my logcat.<

相关标签:
4条回答
  • 2020-11-29 05:33

    You can not use alfa in primary color. The primary color has to be opaque.

    Change:

    <item name="colorPrimaryDark">#4DFF9800</item>
    <item name="colorPrimary">#4D607D8B</item>
    

    To

    <item name="colorPrimaryDark">#FF9800</item>
    <item name="colorPrimary">#607D8B</item>
    

    for api 21 in res/values-v21/style.xml file

    0 讨论(0)
  • 2020-11-29 05:44

    Simple solution to the issue is to remove the opaque applied to the primary color in colors.xml

    When opaque is applied to primary color the color code look like this "#aca688ff", where it has to be ex: "#F50057" (6 letters alphanumeric code without opaque).

    Hope the above solution helps you to fix the issue.

    0 讨论(0)
  • 2020-11-29 05:48

    Error java.lang.RuntimeException: A TaskDescription's primary color should be opaque

    Answer: go to your app-->value-->color and look at your primary color and count the characters there It must have six hexa characters(like #FDEF25).. It must not have more than six characters.

    Here is the video for easiness

    0 讨论(0)
  • 2020-11-29 05:57

    @Konrad Krakowiak is right.
    You can see the source code of android.app.ActivityManager#TaskDescription.

    /**
        * Creates the TaskDescription to the specified values.
        *
        * @param label A label and description of the current state of this task.
        * @param icon An icon that represents the current state of this task.
        * @param colorPrimary A color to override the theme's primary color. This color must be opaque.
        */
        public TaskDescription(String label, Bitmap icon, int colorPrimary) {
          if ((colorPrimary != 0) && (Color.alpha(colorPrimary) != 255)) {
            throw new RuntimeException("A TaskDescription's primary color should be opaque");
          }
    
          mLabel = label;
          mIcon = icon;
          mColorPrimary = colorPrimary;
        }
    
    0 讨论(0)
提交回复
热议问题