Don't cry

[quote]
[size=medium] Talk to me softly
There s something in your eyes
Don t hang your head in sorrow
And please don t cry
I know how you feel inside I ve
I ve been there before
Somethin s changin inside you
And don t you know

Don t you cry tonight
I still love you baby
Don t you cry tonight
Don t you cry tonight
There s a heaven above you baby
And don t you cry tonight

Give me a whisper
And give me a sigh
Give me a kiss before you
tell me goodbye
Don t you take it so hard now
And please don t take it so bad
I ll still be thinkin of you
And the times we had...baby

And don t you cry tonight
Don t you cry tonight
Don t you cry tonight
There s a heaven above you baby
And don t you cry tonight

And please remember that I never lied
And please remember
how I felt inside now honey
You gotta make it your own way
But you ll be alright now sugar
You ll feel better tomorrow
Come the morning light now baby

And don t you cry tonight
An don t you cry tonight
An don t you cry tonight
There s a heaven above you baby
And don t you cry
Don t you ever cry
Don t you cry tonight
Baby maybe someday
Don t you cry
Don t you ever cry
Don t you cry
Tonight[/size]

[/quote]
在 Android 构建过程中,资源文件的命名规则非常重要。如果遇到 **"Android build resource exception: invalid file name, must end with .xml"** 这类错误,通常是因为某个资源文件(预期应为 `.xml` 文件)没有使用正确的扩展名或文件名格式不符合要求。 ### 资源文件命名规范 在 Android 中,资源目录下的 XML 文件必须满足以下条件: - **布局文件**:存放在 `res/layout/` 目录下,例如 `activity_main.xml` - **值资源文件**:如 `res/values/strings.xml`、`res/values/styles.xml` - **动画资源**:`res/anim/` - **菜单资源**:`res/menu/` - **XML 路径定义文件**:如用于 FileProvider 的 `filepaths.xml` 通常放在 `res/xml/` 所有这些文件都必须以 `.xml` 扩展名结尾[^1]。 ### 常见原因及解决方案 #### 1. 文件名拼写错误或缺少 `.xml` 扩展名 确保文件名正确且完整,例如: ```plaintext res/xml/filepaths.xml ✅ res/xml/filepaths ❌ ``` #### 2. 使用了非法字符 Android 不允许资源文件名中包含大写字母、空格、特殊符号等。应使用小写字母和下划线命名法: ```plaintext res/values/my_strings.xml ✅ res/values/MyStrings.xml ❌ res/values/my strings.xml ❌ ``` #### 3. 文件放置位置错误 某些资源类型只能放在特定目录中。例如,用于 `FileProvider` 的 `filepaths.xml` 必须放在 `res/xml/` 目录中,并在清单中通过 `<meta-data>` 引用该资源。 #### 4. Gradle 编译配置问题 有时构建工具未能识别资源变更,可尝试执行以下命令清理项目: ```bash ./gradlew clean ``` 然后重新同步 Gradle 并重建项目。 #### 5. XML 文件内容格式错误 虽然不是直接由文件名引起,但 XML 内容格式错误也可能导致资源解析失败。检查文件是否闭合标签、属性书写是否正确: ```xml <?xml version="1.0" encoding="utf-8"?> <paths> <external-path name="external_files" path="." /> </paths> <!-- 确保所有标签闭合 --> ``` ### 示例:FileProvider 正确配置 若你在使用 `FileProvider`,请确认以下配置: ```xml <provider android:name="androidx.core.content.FileProvider" android:authorities="com.example.fileprovider" android:exported="false" android:grantUriPermissions="true"> <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/filepaths" /> <!-- 注意此处引用的是 xml 类型资源 --> </provider> ``` 同时确保 `res/xml/filepaths.xml` 存在并格式正确: ```xml <?xml version="1.0" encoding="utf-8"?> <paths> <external-path name="external_files" path="." /> </paths> ``` ### 验证方式 可以使用如下代码片段来验证资源是否存在: ```java try { Resources res = context.getResources(); int resourceId = res.getIdentifier("filepaths", "xml", context.getPackageName()); if (resourceId != 0) { // 资源存在 } else { // 资源不存在,可能是文件名错误或路径不对 } } catch (Exception e) { e.printStackTrace(); } ``` ---
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值