Manifest and setup issues getting Robolectric working with Android Studio 1.1.0

前端 未结 6 1671
盖世英雄少女心
盖世英雄少女心 2021-01-18 07:29

I am trying to get Robolectric tests up and working in our current project, and not having a lot of luck. My preference would be to get these to run within Android Studio 1

6条回答
  •  醉酒成梦
    2021-01-18 08:12

    After few days struggling, I eventually figured out the root cause of your question:

    WARNING: No manifest file found at ./AndroidManifest.xml.Falling back to the Android OS resources only. messages, or API Level XX is not supported - Sorry!
    

    Many answers I found on stackOverFlow told me to add the path of Manifest file to the @Config like this:

    @Config(manifest = "src/main/AndroidManifest.xml")
    

    It did work for one of my projects, but when I opened a new project and set up the testing environment, same error message popped up.

    The reason behind this would be the different working directory of your project. You should locate your working directory first, and then specify the relative path to it in your @Config(maniest = "...").

    Where can I find Working directory in Android Studio?

    Run -> Edit Configurations -> Junit -> Your Test 
    -> Configuration Tab -> **Working directory:**
    

    Take my working directory as an example, my working directory is

    "/Users/Bible/AndroidstudioProjects/MVP"
    

    so the path to my AndroidManifest.xml should be

    @Config(manifest = "app/src/main/AndroidManifest.xml")
    

    Here you go! Hope this answer can make your life easier.

提交回复
热议问题