I have a lot of files required for my JUnit testing that I don't want to include in the app when it is downloaded (a lot of them are bitmaps that would take up space). Currently all files are stored in the assets folder. Is there a directory I can put the files in that won't be included when the app is downloaded?
Asked
Active
Viewed 53 times
0
-
Maybe this helps you: http://stackoverflow.com/questions/12617827/gradle-1-2-exclude-directory-under-resources-sourcesets – Héctor Dec 16 '14 at 08:20
-
Related: [Exclude Test files from final build of android app](http://stackoverflow.com/q/23049782) – Duncan Jones Dec 16 '14 at 08:48
-
Show us your current directory structure and how you are using them in tests (some code). – Zoltán Dec 16 '14 at 09:21
1 Answers
0
We have a similar situation.
Create a new java library and place all the files you need in your tests under src/main/resources
. Don't use src/test/resources
or you won't have visibility of the files.
Then simply import the module as part of your test dependencies.
testCompile project(':files-module') // for java modules
or
androidTestCompile project(':files-module') // for android modules
You should then be able to gain access to the files through getResourceAsStream("/" + filename)
Because the module is only used as a dependency in tests nothing will be included in your production code.

Phil H
- 897
- 4
- 10