Issue
Is there a difference between res/
and resources/
.?? If I simply create a new directory and title it resources
, it is not displayed as a normal directory, seems like resources
is a keyword unlike temp
which shows as a normal directory.
We commonly name a resource folder res
in the lib directory to hold drawables, values, layout, etc..
and then in the test
directory we put sample json and other items needed for testing in resources
. I'm just wondering if there is actually a difference between these?
Thanks
Solution
The test
folder contains code (usually test code, unit tests, etc...) that runs on your local PC or laptop. The code compiled and eventually run using the installed Java on your machine the same way as pure Java projects with some minor differences. So basically the purpose of the test
folder is to test parts of application code that don't have a dependency on the Android SDK and without using an Android device. Also on the side, there's another test folder which is androidTest
, it also used for testing parts of the application but with using an Android device, meaning an actual test application is loaded on the device and it executes the tests which have a dependency on the Android SDK.
That being said, pure Java projects or code usually use resources
folder and not res
(as far I have seen while using IDEs). When compiling and then running the pure Java projects or code, the contents of the resources
folder are placed at the root of the Java classpath so that the code being executed finds its resources
there.
Android Studio or the Android Gradle Plugin seems to handle both differently (in terms of packaging them into the final aar
or apk
), so it is best that there is only res
in main
or androidTest
folder and also that there is only resources
in test
folder.
Answered By - ahasbini
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.