java - 突然之间,我无法在 Android Studio 中更改任何字符串

标签 java android string android-studio

我正在使用 Google+ API 并尝试将聊天添加到我的应用程序(不使用 Google 运行聊天)。聊天部分很简单,但我无法突然更改字符串以在撇号前添加反斜杠。另外,它添加了 <resources xmlns:ns1="urn:oasis:names:tc:xliff:document:1.2"> ,我不知道为什么会出现这种情况,也不知道它意味着什么。

我的 strings.xml 文件(不是整个文件):

<!-- Top of file -->
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:ns1="urn:oasis:names:tc:xliff:document:1.2">


<string name="common_android_wear_notification_needs_update_text"><ns1:g id="app_name">%1$s</ns1:g> requires an update to the Android Wear app.</string>
<string name="common_android_wear_update_text"><ns1:g id="app_name">%1$s</ns1:g> won\'t run unless you update the Android Wear app.</string>
<string msgid="6006316683626838685" name="common_android_wear_update_title">Update Android Wear</string>
<string name="common_google_play_services_api_unavailable_text"><ns1:g id="app_name">%1$s</ns1:g> requires one or more Google Play services that are not currently available. Please contact the developer for assistance.</string>
<string msgid="2523291102206661146" name="common_google_play_services_enable_button">Enable Google Play services</string>
<string msgid="227660514972886228" name="common_google_play_services_enable_text"><ns1:g id="app_name">%1$s</ns1:g> won\'t work unless you enable Google Play services.</string>
<string msgid="5122002158466380389" name="common_google_play_services_enable_title">Enable Google Play services</string>
<string name="common_google_play_services_error_notification_requested_by_msg">Requested by <ns1:g id="app_name">%1$s</ns1:g></string>
<string msgid="7153882981874058840" name="common_google_play_services_install_button">Get Google Play services</string>
<string msgid="2122112764540849864" name="common_google_play_services_install_text_phone"><ns1:g id="app_name">%1$s</ns1:g> won\'t run without Google Play services, which are missing from your phone.</string>
<string msgid="7351599665250191022" name="common_google_play_services_install_text_tablet"><ns1:g id="app_name">%1$s</ns1:g> won\'t run without Google Play services, which are missing from your tablet.</string>
<string msgid="7215213145546190223" name="common_google_play_services_install_title">Get Google Play services</string>
<string name="common_google_play_services_invalid_account_text">The specified account does not exist on this device. Please choose a different account.</string>
<string name="common_google_play_services_invalid_account_title">Invalid Account</string>
<string name="common_google_play_services_needs_enabling_title">An application requires Google Play services to be enabled.</string>
<string name="common_google_play_services_network_error_text">A data connection is required to connect to Google Play services.</string>
<string name="common_google_play_services_network_error_title">Network Error</string>
<string name="common_google_play_services_notification_needs_update_title">An application requires an update for Google Play services.</string>
<string name="common_google_play_services_notification_ticker">Google Play services error</string>
<string name="common_google_play_services_sign_in_failed_text">Error signing in the specified account. Please choose a different account.</string>
<string name="common_google_play_services_sign_in_failed_title">Sign in failed</string>
<string name="common_google_play_services_unknown_issue">Unknown issue with Google Play services.</string>
<string name="common_google_play_services_unsupported_text"><ns1:g id="app_name">%1$s</ns1:g> relies on Google Play services, which is not supported by your device. Contact the manufacturer for assistance.</string>
<string name="common_google_play_services_unsupported_title">Google Play services</string>
<string msgid="6556509956452265614" name="common_google_play_services_update_button">Update</string>
<string msgid="9053896323427875356" name="common_google_play_services_update_text"><ns1:g id="app_name">%1$s</ns1:g> won\'t run unless you update Google Play services.</string>
<string msgid="6006316683626838685" name="common_google_play_services_update_title">Update Google Play services</string>
<string name="common_google_play_services_updating_text"><ns1:g id="app_name">%1$s</ns1:g> won\'t run without Google Play services, which are currently updating.</string>
<string name="common_google_play_services_updating_title">Google Play services are updating</string>
<string name="common_open_on_phone">Open on phone</string>
<string name="common_signin_button_text">Sign in</string>
<string name="common_signin_button_text_long">Sign in with Google</string>
<string name="disk_cache_description">On Ice Cream Sandwich and above, a disk cache is
automatically used so that subsequent requests for the same URL do not re-download the
image.\n\nTo enable this functionality on pre-ICS use a standalone HTTP client with caching such
as OkHttp.
</string>
<string name="easter_egg">I am an easter egg!</string>
<string name="edit">Edit</string>
<string name="email">Email</string>
<string name="err_fields_empty">Please fill all the fields.</string>
<string name="err_login">Error occurred while login:</string>
<string name="err_singup">Error occurred while signup:</string>
<string name="err_users">Error occurred while finding users:</string>
<string name="error_a">Error with Activity</string>
<string name="error_b">Unable to launch the specified Activity or the link was to this page. Check back later.</string>
<string name="error_field_required">This field is required</string>
<string name="error_incorrect_password">This password is incorrect</string>
<string name="error_invalid_email">This email address is invalid</string>
<string name="error_invalid_password">This password is too short</string>
<string name="fetch_content_base">Fetching content. Please wait.</string>
<string name="forgot_my_pwd">I can't remember my password!</string>

forgot_my_pwd字符串有撇号,我试图添加反斜杠,但每当我构建、编译或清理时,它都会删除更改并说 Error:(307) Apostrophe not preceded by \ (in I can't remember my password!) .添加几个字符串时几乎没有发生这种情况,我认为这不会改变任何事情。感谢您提供任何帮助,因为我已经没有解决此问题的线索。谢谢!

最佳答案

我已经为所有遇到同样问题的观众发布了这个答案。所有这些步骤都在主要帖子的评论中进行了解释,但这里是重写的步骤:

首先,检查您正在查看的strings.xmlvalues.xml 文件是否不是系统文件。为了判断它是否是系统文件,文件的选项卡将是浅黄色,如下所示。

Light yellow values.xml file tab

如果它等同于显示的图像,则它是一个构建文件,并且无法编辑。

要导航到可编辑文件,请确保文件树上的 View 在此处设置为“Android”:

Dropdown menu image

现在,导航到文件浏览器中圈出的文件,如下图所示:

File tree strings.xml image

导航到该文件后,您应该能够更改所需字符串的值。

关于java - 突然之间,我无法在 Android Studio 中更改任何字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35045983/

相关文章:

android - NestedScrollView 在使用 nestedScrollEnabaled 属性时抛出错误 "android.view.InflateException"

php - 如果字符串只包含空格?

java - springMVC,如何删除链接(href)

java - 如何从复选框 onchange 事件获取 id

带有两个拇指的 Android Seekbar

java - 如何将文件 bundle 到应用程序中?

php - 使用 var_dump 时 string() “value"是什么意思

java - 如何返回超过 1 个值的字符串?

java - 如何对通过@JsonCreator 组成的枚举进行单元测试?

java - 为什么 JUnit 不提供 assertNotEquals 方法?