Drawable资源:重新打包资源失败,详见控制台
Drawable resources: Failed to re-package resources, see the console for details
在我的 AndroidManifest.xml 文件中,我有这些行:
<meta-data android:name="com.google.android.vr.icon"
android:resource="@drawable/front_icon" />
<meta-data android:name="com.google.android.vr.icon_background"
android:resource="@drawable/back_icon" />
这些行指定了用于 VR 应用程序图标的图标文件,并且 are required for Daydream。不幸的是,关于这些文件去向的说明不清楚:
Note: Assets for VR should be placed inside the nodpi/ resource directory to ensure display density scaling is not applied on load.
我应该将这些文件放在我的 Unity 项目中的什么位置?
我尝试构建时的错误是
Failed to re-package resources. See the console for details.
在控制台中使用这个(错误从其庞大的 4000 行减少到相关信息):
CommandInvokationFailure: Failed to re-package resources.
stderr[
AndroidManifest.xml:6: error: Error: No resource found that matches the given name
(at 'resource' with value '@drawable/front_icon').
AndroidManifest.xml:7: error: Error: No resource found that matches the given name
(at 'resource' with value '@drawable/back_icon').
]
清单文件位于 Assets/Plugins/Android
目录中,res
目录位于 Assets/Plugins/Android/res
我试过:
res/drawable
res/drawable/nodpi
res/nodpi/drawable
res/nodpi
在该文件夹中包含 front_icon.png 和 back_icon.png。 None 其中有效。
你几乎是正确的。您要的文件夹是
res/drawable-nodpi
您可以找到有关 Android 如何指定这些文件夹 here, which I got to by first finding this page on providing resources 的文档,搜索 "nodpi",然后单击 "See Supporting Multiple Screens for more information" link,然后只需要找到正确的部分。
在靠近页面顶部 ("The configuration qualifiers (described in detail below)") 的标题 "How to Support Multiple Screens" 下有一个 link,它让我在浏览页面内容时转到了正确的部分。
To use a configuration qualifier:
Create a new directory in your project's res/
directory and name it using the format: <resources_name>-<qualifier>
<resources_name>
is the standard resource name (such as drawable or layout).
<qualifier>
is a configuration qualifier from table 1, below, specifying the screen configuration for which these resources are to be used (such as hdpi
or xlarge
).
You can use more than one <qualifier>
at a time—simply separate each qualifier with a dash.
- Save the appropriate configuration-specific resources in this new directory. The resource files must be named exactly the same as the default resource files.
For example, xlarge
is a configuration qualifier for extra-large screens. When you append this string to a resource directory name (such as layout-xlarge
), it indicates to the system that these resources are to be used on devices that have an extra-large screen.
我绝对认为,从 Unity 开发人员的角度来看,这些信息确实感觉很隐蔽,因为它是 Android 的东西,而且您从中开始的相关页面没有包含 link 回到支持文档,因为它假设您已经熟悉指定其他资源(Unity 会自动为您处理)。
在我的 AndroidManifest.xml 文件中,我有这些行:
<meta-data android:name="com.google.android.vr.icon"
android:resource="@drawable/front_icon" />
<meta-data android:name="com.google.android.vr.icon_background"
android:resource="@drawable/back_icon" />
这些行指定了用于 VR 应用程序图标的图标文件,并且 are required for Daydream。不幸的是,关于这些文件去向的说明不清楚:
Note: Assets for VR should be placed inside the nodpi/ resource directory to ensure display density scaling is not applied on load.
我应该将这些文件放在我的 Unity 项目中的什么位置?
我尝试构建时的错误是
Failed to re-package resources. See the console for details.
在控制台中使用这个(错误从其庞大的 4000 行减少到相关信息):
CommandInvokationFailure: Failed to re-package resources.
stderr[ AndroidManifest.xml:6: error: Error: No resource found that matches the given name (at 'resource' with value '@drawable/front_icon'). AndroidManifest.xml:7: error: Error: No resource found that matches the given name (at 'resource' with value '@drawable/back_icon'). ]
清单文件位于 Assets/Plugins/Android
目录中,res
目录位于 Assets/Plugins/Android/res
我试过:
res/drawable
res/drawable/nodpi
res/nodpi/drawable
res/nodpi
在该文件夹中包含 front_icon.png 和 back_icon.png。 None 其中有效。
你几乎是正确的。您要的文件夹是
res/drawable-nodpi
您可以找到有关 Android 如何指定这些文件夹 here, which I got to by first finding this page on providing resources 的文档,搜索 "nodpi",然后单击 "See Supporting Multiple Screens for more information" link,然后只需要找到正确的部分。
在靠近页面顶部 ("The configuration qualifiers (described in detail below)") 的标题 "How to Support Multiple Screens" 下有一个 link,它让我在浏览页面内容时转到了正确的部分。
To use a configuration qualifier:
Create a new directory in your project's
res/
directory and name it using the format:<resources_name>-<qualifier>
<resources_name>
is the standard resource name (such as drawable or layout).<qualifier>
is a configuration qualifier from table 1, below, specifying the screen configuration for which these resources are to be used (such ashdpi
orxlarge
).You can use more than one
<qualifier>
at a time—simply separate each qualifier with a dash.
- Save the appropriate configuration-specific resources in this new directory. The resource files must be named exactly the same as the default resource files.
For example,
xlarge
is a configuration qualifier for extra-large screens. When you append this string to a resource directory name (such aslayout-xlarge
), it indicates to the system that these resources are to be used on devices that have an extra-large screen.
我绝对认为,从 Unity 开发人员的角度来看,这些信息确实感觉很隐蔽,因为它是 Android 的东西,而且您从中开始的相关页面没有包含 link 回到支持文档,因为它假设您已经熟悉指定其他资源(Unity 会自动为您处理)。