【问题标题】:What's the path for resources under a flavor folder?风味文件夹下的资源路径是什么?
【发布时间】:2015-05-08 17:41:33
【问题描述】:

我正在尝试使用 Espresso 编写一些集成测试,而我的代码正在使用 Picasso 使用

加载图像
picasso.load(path);

下面的调用

Uri.parse(path);

我想为这些图片提供本地资源

app -> src -> 风味 -> 资源

这样我就可以成为一名优秀的测试公民,而不是在我的测试中进行网络调用。

我的 Google-Fu 今天不太好,因为我找不到这方面的任何信息,所以我的问题是,这个文件夹下的资源路径是什么,所以我可以让 Picasso 在测试中加载我的本地资源?

我试过了

file://resources/image_name.jpg

但这不起作用。

【问题讨论】:

  • 很遗憾,这不起作用。

标签: android unit-testing integration-testing picasso android-espresso


【解决方案1】:

将文件放入:

app/src/main/assets/sample.png

然后像这样加载:

Picasso.with(this)
    .load("file:///android_asset/sample.png")
    .into(imageView);

编辑:

或者把文件放进去

app/src/main/res/raw/sample.png

并像这样加载:

Picasso.with(this)
    .load(R.raw.sample)
    .into(imageView);

【讨论】:

    猜你喜欢
    • 2022-07-01
    • 2018-12-19
    • 1970-01-01
    • 1970-01-01
    • 2011-08-25
    • 2014-03-07
    • 2017-08-30
    • 2011-03-07
    • 1970-01-01
    相关资源
    最近更新 更多