You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

创建资源文件时无法添加raw类型资源,求原因解答

Why Can't I Select raw as a Resource Type When Creating a New Resource File?

Hey there! Let's walk through the common reasons you're hitting this issue and how to fix them step by step:

  • You’re using the wrong template for resource creation
    When you try to create a "new resource file" directly, templates like Values Resource File or Layout Resource File are locked to their specific types—they won’t show raw as an option because raw is meant for unprocessed files (audio, video, plain text, etc.) that stay in their original format.
    Fix: Right-click your project’s res folder → choose New → Android Resource Directory. In the popup, set the Resource type dropdown to raw, then hit OK. Once the raw folder exists, you can drag-and-drop files into it, or right-click the folder and select New → File to add your resource directly.

  • Your project view is set to the wrong mode
    If you’re viewing your project in "Project" or "Packages" mode, the option to create a raw resource directory might be hidden or not accessible through the standard workflow.
    Fix: Switch to the Android view (use the dropdown in the top-left corner of the Project window). This organizes your files into the standard Android structure, making resource-specific options easy to find.

  • Project configuration files are corrupted
    Sometimes, cached data or messed-up Gradle/.idea files can cause missing resource options.
    Fixes:

    1. Go to File → Invalidate Caches... → select "Invalidate and Restart" to clear Android Studio’s cache and restart the IDE.
    2. If that doesn’t help, click the Sync Project with Gradle Files icon (the little elephant in the toolbar) to re-sync your project’s build configuration.
    3. As a last ditch effort, manually create the raw folder: navigate to app/src/main/res, make a folder named raw (all lowercase), and Android Studio will automatically recognize it as a valid resource directory.

内容的提问来源于stack exchange,提问作者Johanna

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 04:20:47