0

In my project, I have an app module with instrumentation tests.
They use code from a library module which needs additional permissions that should normally not be included in the app. (WRITE_EXTERNAL_STORAGE)

I have put the permission in the libraries manifest and included it in the apps build.gradle using androidTestImplementation.

Unfortunately when I run the test it fails because the manifest of the installed application does not contain the required permission.

I also tried writing to context.filesDir since that should not require any permission, but it also fails with "Permission denied"

How can my library code write to the file system without the app module manifest having to include the permission?

000000000000000000000
  • 1,467
  • 1
  • 19
  • 38
  • Have you checked this solution?: https://stackoverflow.com/a/45320863/2910520 – MatPag Apr 16 '19 at 15:39
  • Thanks, but I cannot grant a permission that was not declared in the manifest. I do have the permission declared in my library module, but it is not included in the app module that uses the library. – 000000000000000000000 Apr 16 '19 at 15:42
  • If you import a library which is declaring this permission, you will find this permission in your app too because manifests will be merged togheter – MatPag Apr 16 '19 at 15:46
  • Yes, but the library is only used by the instrumentation tests of the app (`androidTestImplementation`) – 000000000000000000000 Apr 16 '19 at 16:18

0 Answers0