Android test raw resource

前端 未结 3 796
别那么骄傲
别那么骄傲 2021-01-01 08:31

I have the following folder structure in Android Studio:

├── androidTest
│   ├── java
│   └── res
│       └── raw
│           └── test_file
└── main
    ├──          


        
3条回答
  •  盖世英雄少女心
    2021-01-01 09:08

    I had the androidTest resources in the right spot (src/androidTest/res) and I still couldn't access them via .test.R. I spent a lot of time googling trying to figure out what was going on..

    I FINALLY stumbled onto the answer. If you're building a buildType where you specified an applicationIdSuffix, your files are at .test.R !!!!

    i.e.

    applicationId "com.example.my.app"
    
    buildTypes {
        debug {
            applicationIdSuffix ".debug"
        }
    }
    

    if you have androidTest resources in the right directory, then you can only access them via com.example.my.app.debug.test.R !!!!

提交回复
热议问题