Skip to content
Advertisement

Tag: android-resources

android.content.res.Resources$NotFoundException – /res/color/file.xml

I’m trying to implement the Color State List Resources in my android application, following Android developer guide Color State List Resource | Android Developers. So I created two resource files button_text.xml and button_background.xml in the directory res/color/ and referred them in the with @color/button_text and @color/button_background respectively in the activity_main.xml. Here’s the layout code: On running the App, I’m getting

Assets folder in Android Studio Unit Test

I have a Gradle project with the following structure: Now I want to add a unit test which uses a resource (either “raw” or “asset”). I put my resource into project/androidTest/assets/test_file and access it with getContext().getResources().getAssets().open(“test_file”); (in an AndroidTestCase). However, this gives me a FileNotFoundException. How can I fix this? Answer It looks like you’re trying to create an instrumented

Advertisement