android / android/nowinandroid

[Bug]: Permission: android.permission.WRITE_EXTERNAL_STORAGE cannot be granted! while running Macrobenchmark

Open
#796 3 comments 1 reaction 0 assignees View on GitHub
bug
Dominant language
Kotlin
Stars
21.8k
Forks
4.6k
Avg merge
19h 20m
Merged PRs (30d)
2

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Is there a StackOverflow question about this issue?

- [X] I have searched StackOverflow

### What happened?

# Brief
While trying to build and test the benchmark module. I wanted to run the sample benchmark `WarmStartupBenchmark`. I just cloned the repo and did basic setup of the repository and installed the app that ran successfully after which I decided to run the benchmark.

# Issue
The build runs successfully but the test cases fails with an error message shown bellow.
```
Permission: android.permission.WRITE_EXTERNAL_STORAGE cannot be granted!
```
This says that it cannot grant permissions for storage, which certainly should not be the case. I have seen this issue with every benchmarking repository that I tried from google. Recently, I tried the [codelab](https://github.com/googlecodelabs/android-performance) for benchmarking in android which has the same issue.

I have also researched about it and found an open issue in (IssueTracker)[https://issuetracker.google.com/issues/235344525].

# Device Details
Android Studio Version : Flamingo
Android Version : 11 (Physical Device)
Device Name : Redmi Note 8 Pro.

### Relevant logcat output

```shell
Requesting permission: pm grant com.google.samples.apps.nowinandroid.benchmarks android.permission.WRITE_EXTERNAL_STORAGE
2023-06-13 14:37:06.458 30426-30476 UiAutomation com....apps.nowinandroid.benchmarks W UiAutomation.grantRuntimePermission() is more robust and should be used instead of 'pm grant'
2023-06-13 14:37:07.476 30426-30476 GrantPermissionCallable com....apps.nowinandroid.benchmarks E Permission: android.permission.WRITE_EXTERNAL_STORAGE cannot be granted!
2023-06-13 14:37:07.476 30426-30476 TestRunner com....apps.nowinandroid.benchmarks E failed: startupBaselineProfileDisabled(com.google.samples.apps.nowinandroid.startup.WarmStartupBenchmark)
2023-06-13 14:37:07.476 30426-30476 TestRunner com....apps.nowinandroid.benchmarks E ----- begin exception -----
2023-06-13 14:37:07.478 30426-30476 TestRunner com....apps.nowinandroid.benchmarks E junit.framework.AssertionFailedError: Failed to grant permissions, see logcat for details
at junit.framework.Assert.fail(Assert.java:50)
at androidx.test.runner.permission.PermissionRequester.requestPermissions(PermissionRequester.java:111)
at androidx.test.rule.GrantPermissionRule$RequestPermissionStatement.evaluate(GrantPermissionRule.java:135)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
at androidx.test.internal.runner.TestExecutor.execute(TestExecutor.java:67)
at androidx.test.internal.runner.TestExecutor.execute(TestExecutor.java:58)
at androidx.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:446)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:2207)
2023-06-13 14:37:07.478 30426-30476 TestRunner com....apps.nowinandroid.benchmarks E ----- end exception -----
```

### Code of Conduct

- [X] I agree to follow this project's Code of Conduct

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the failure with the sample benchmark WarmStartupBenchmark on the stated Android 11 setup, then trace the permission request shown in the log through GrantPermissionRule and PermissionRequester. Done means the benchmark runs without the WRITE_EXTERNAL_STORAGE grant failure, with the relevant behavior verified in the benchmark run.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, kotlin
Domain
mobile, testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.