Robolectric: Resources$NotFoundException: String resource ID with Android Gradle Plugin 3

后端 未结 8 1677
别那么骄傲
别那么骄傲 2020-12-15 03:08
Android Studio 3.0 Beta2
classpath \'com.android.tools.build:gradle:3.0.0-beta3\'
testCompile \'org.robolectric:robolectric:3.4.2\'

Test class that

8条回答
  •  粉色の甜心
    2020-12-15 03:44

    (for anyone that might be looking for a solution to a similar problem)


    Be sure to use

    RuntimeEnvironment.application
    

    and not:

    RuntimeEnvironment.systemContext
    

    when you're trying to resolve resources "manually".

    That's one case in which Resources$NotFoundException might show up with Robolectric.

提交回复
热议问题