Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/217.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 5.1崩溃-任务描述';s的原色应该是不透明的_Android_Crash_Material Design - Fatal编程技术网

Android 5.1崩溃-任务描述';s的原色应该是不透明的

Android 5.1崩溃-任务描述';s的原色应该是不透明的,android,crash,material-design,Android,Crash,Material Design,我已经在我的应用程序中实现了材质设计,它在

我已经在我的应用程序中实现了材质设计,它在
     FATAL EXCEPTION main
 Process com.test.test, PID 3195
 java.lang.RuntimeException Unable to start activity ComponentInfo{com.test.test/com.test.test.MainActivity} java.lang.RuntimeException A TaskDescription's primary color should be opaque
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java2298)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java2360)
    at android.app.ActivityThread.access$800(ActivityThread.java144)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java1278)
    at android.os.Handler.dispatchMessage(Handler.java102)
    at android.os.Looper.loop(Looper.java135)
    at android.app.ActivityThread.main(ActivityThread.java5221)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java899)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java694)
 Caused by java.lang.RuntimeException A TaskDescription's primary color should be opaque
    at android.app.ActivityManager$TaskDescription.<init>(ActivityManager.java536)
    at android.app.Activity.onApplyThemeResource(Activity.java3677)
    at android.view.ContextThemeWrapper.initializeTheme(ContextThemeWrapper.java140)
    at android.view.ContextThemeWrapper.setTheme(ContextThemeWrapper.java85)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java2244)
    ... 10 more
main致命异常
过程com.test.test,PID 3195
java.lang.RuntimeException无法启动活动组件信息{com.test.test/com.test.test.MainActivity}java.lang.RuntimeException TaskDescription的主颜色应为不透明
在android.app.ActivityThread.performLaunchActivity(ActivityThread.java2298)上
位于android.app.ActivityThread.handleLaunchActivity(ActivityThread.java2360)
在android.app.ActivityThread.access$800(ActivityThread.java144)
在android.app.ActivityThread$H.handleMessage(ActivityThread.java1278)
位于android.os.Handler.dispatchMessage(Handler.java102)
位于android.os.Looper.loop(Looper.java135)
位于android.app.ActivityThread.main(ActivityThread.java5221)
位于java.lang.reflect.Method.invoke(本机方法)
位于java.lang.reflect.Method.invoke(Method.java372)
在com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java899)上
位于com.android.internal.os.ZygoteInit.main(ZygoteInit.java694)
由java.lang.RuntimeException引起的TaskDescription的主颜色应为不透明
在android.app.ActivityManager$TaskDescription。(ActivityManager.java536)
在android.app.Activity.onApplyThemeResource(Activity.java3677)上
在android.view.ContextThemeWrapper.InitializeTime(ContextThemeWrapper.java140)中
位于android.view.ContextThemeWrapper.setTheme(ContextThemeWrapper.java85)
在android.app.ActivityThread.performLaunchActivity(ActivityThread.java2244)上
... 10多
以下是我的风格:

    <resources>

    <!--
        Base application theme, dependent on API level. This theme is replaced
        by AppBaseTheme from res/values-vXX/styles.xml on newer devices.


    -->


    <!-- All customizations that are NOT specific to a particular API-level can go here. -->

    <style name="AppTheme" parent="@style/Theme.AppCompat.NoActionBar">

        <!-- All customizations that are NOT specific to a particular API-level can go here. -->

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

</resources>

#4DF9800
#4D607D8B

如果有人能给我一些指导,那将非常感谢。

您不能在原色中使用阿尔法。原色必须是不透明的

更改:

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

#FF9800
#607D8B

对于
res/values-v21/style.xml文件中的api 21来说

@Konrad Krakowiak是正确的。
你可以看到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;
    }

解决此问题的简单方法是删除colors.xml中应用于原色的不透明颜色

当不透明应用于原色时,颜色代码如下所示“#aca688ff”,其中必须为ex:#F50057”(不带不透明的6个字母数字代码)


希望上述解决方案能帮助您解决问题。

我自己没有使用此解决方案。我测试了安卓6。0@SathishKumarJ你能用你的代码创建gist吗?在这里检查我的问题,请澄清在哪些情况下它必须是不透明的,因为我可以在棉花糖6.0.1上为colorPrimary使用透明颜色,没有任何问题。。我没有棒棒糖设备,所以无法测试。安卓6没有问题,安卓4.4没有问题,但安卓5.1会引发此异常!!!难道没有一个好的解决方案不需要降低我的应用程序的颜色吗?
/**
    * 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;
    }