简体   繁体   中英

Raw resources aren't resolvable in android tests

R.raw.... resources that are located in src/androidTest/res/raw can't be resolved in android tests after updating Android build tools to 4.7.3. Resources were resolvable before updating build tools.

com.santaev.app.test.R isn't resolved.

Build output: Unresolved reference: test

Android build tools 4.7.3 introduces namespace and testNamespace settings that allows to set package or generated file like R . Default values is same to package. com.example.myapp.R and com.example.myapp.test.R for tests).

See https://developer.android.com/studio/build/configure-app-module#change-namespace-for-testing .

Looks like that after updating build tools property testApplicationId isn't more supported that leads manifest package to be used as namespace.

Removing package from manifest of android test sources and removing testApplicationId :

defaultConfig {
    // ...
    testApplicationId 'com.example.myapp.test.R' 
}

helped me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM