material-components / material-components/material-components-android
[DynamicColors] StrictMode Violation in DynamicColors.applyToActivityIfAvailable
@pekingme is already working on this.
Since May 18, 2023.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.