material-components / material-components/material-components-android

[DynamicColors] StrictMode Violation in DynamicColors.applyToActivityIfAvailable

Open
#3,413 4 comments 0 reactions 1 assignee View on GitHub

@pekingme is already working on this.

Since May 18, 2023.

bug Feature: Color
Dominant language
Java
Stars
17.4k
Forks
3.2k
PR merge metrics
No merged PRs in 30d

Description

When calling applyToActivityIfAvailable in Activity's onCreate, as explained in the documentation, with StrictMode activated, the following violation is raised:

```
StrictMode policy violation; ~duration=135 ms: android.os.strictmode.DiskWriteViolation
at android.os.StrictMode$AndroidBlockGuardPolicy.onWriteToDisk(StrictMode.java:1615)
at libcore.io.BlockGuardOs.write(BlockGuardOs.java:446)
at libcore.io.ForwardingOs.write(ForwardingOs.java:951)
at libcore.io.IoBridge.write(IoBridge.java:649)
at java.io.FileOutputStream.write(FileOutputStream.java:401)
at java.io.FileOutputStream.write(FileOutputStream.java:379)
at com.google.android.material.color.ColorResourcesLoaderCreator.create(ColorResourcesLoaderCreator.java:56)
at com.google.android.material.color.ResourcesLoaderUtils.addResourcesLoaderToContext(ResourcesLoaderUtils.java:35)
at com.google.android.material.color.ResourcesLoaderColorResourcesOverride.applyIfPossible(ResourcesLoaderColorResourcesOverride.java:66)
at com.google.android.material.color.ResourcesLoaderColorResourcesOverride.applyIfPossible(ResourcesLoaderColorResourcesOverride.java:50)
at com.google.android.material.color.DynamicColors.applyToActivityIfAvailable(DynamicColors.java:331)
```

**Android API version:** 32

**Material Library version:** 1.10.0-alpha03

**Device:** API 32 emulator

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.