Random FileNotFoundException when mocking Android class
Open
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 2k
- Forks
- 262
- PR merge metrics
- No merged PRs in 30d
Description
Hi I've encountered this few times on CI but I couldn't reproduce this. When I try to mock NotificationManager class I recevice such error (on different devices):
| Caused by: java.io.FileNotFoundException: /data/user/0/com.example.app/app_dxmaker_cache/Generated_1912252465.jar: open failed: EACCES (Permission denied)
-- | --
2022-10-17T15:41:27.230Z | error | TestRunner | at libcore.io.IoBridge.open(IoBridge.java:575)
2022-10-17T15:41:27.230Z | error | TestRunner | at java.io.FileOutputStream.<init>(FileOutputStream.java:236)
2022-10-17T15:41:27.230Z | error | TestRunner | at java.io.FileOutputStream.<init>(FileOutputStream.java:186)
2022-10-17T15:41:27.230Z | error | TestRunner | at com.android.dx.DexMaker.generateAndLoad(DexMaker.java:537)
2022-10-17T15:41:27.230Z | error | TestRunner | at com.android.dx.stock.ProxyBuilder.buildProxyClass(ProxyBuilder.java:337)
2022-10-17T15:41:27.230Z | error | TestRunner | at com.android.dx.mockito.DexmakerMockMaker.createMock(DexmakerMockMaker.java:121)
2022-10-17T15:41:27.230Z | error | TestRunner | at org.mockito.internal.util.MockUtil.createMock(MockUtil.java:35)
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.
Research direction
Start by investigating the NotificationManager mocking path shown in the stack trace, especially DexMaker.generateAndLoad and ProxyBuilder.buildProxyClass, and try to reproduce the permission failure on CI or affected devices. Done means the intermittent FileNotFoundException is understood and the mocking flow no longer fails with EACCES.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- mobile-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100