references to other resources are not supported by build-time PNG generation 解决办法
目录
刚刚升级 Android Studio 3.0 后重新编译项目,就碰到了莫名奇妙的图片载入错误,好在万能的 Google 在。
错误信息非常长,而且比较多重复,有用的就是下面的内容:
|
|
在上面提示的网页中可以知道新的 Android Studio 加入了 Vector Asset Studio 来帮助程序员向项目中添加 MD 图标,以及将 SVG 或 PSD 图像导入为矢量(vector)图像资源。毕竟,尽量使用矢量图像避免使用位图(bitmap)可以极大地减少 apk 尺寸。当然,旧版本 Android 系统未必支持矢量图资源,即使如此 Vector Asset Studio 也能在项目 build 的时候构造不同尺寸的位图文件。 这里我的项目最低 sdk 版本是 16,这个 Android 系统版本不支持矢量图资源,可以使用简单的方法使图片自动生成对应尺寸的位图文件,即修改 app 模块的 Gradle 文件如下:
|
|
然后,build 就没有问题了(不放心可以先 clean 一下)。