linkedin / linkedin/dexmaker

Random FileNotFoundException when mocking Android class

Open
#185 5 comments 0 reactions 0 assignees View on GitHub

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

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.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.