Rafael Pacheco Rafael Pacheco - 16 days ago 12
Android Question

How find support library resources using robolectric?

I'm trying using robolectric to mock somethings on my android app tests. Sadly after I include a external library on my project the tests crashed.
Error info is about some library resource not found.

java.lang.RuntimeException: Could not find any resource from reference ResName{com.company.app:style/Theme_AppCompat_Light_NoActionBar} from style StyleData{name='AppTheme_Base', parent='Theme_AppCompat_Light_NoActionBar'} with theme null


Someone have this problem ?

Answer

Libraries that contain internal resources (AKA aar) need to be mapped on project.properties files (at src/main). The file content will be something like this (if you are using Android Studio):

android.library.reference.1=../app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/21.0.0

Take a look at the documentation.