Android 未找到与给定名称匹配的资源

Android 未找到与给定名称匹配的资源,android,resources,manifest,Android,Resources,Manifest,这: 是我的AndroidManifest.xml,在第8行和第11行我得到了错误: 找不到与匹配的资源 给定名称(在带有值的“标签”处 “@string/app_name”) 找不到与匹配的资源 给定名称(在带有值的“标签”处 “@string/app_name”) 这真的很奇怪,我没有将values文件夹移动到任何地方。是否检查以确保在res/values/strings.xml中定义了字符串资源 <?xml version="1.0" encoding="utf-8"?>

这:


是我的
AndroidManifest.xml
,在第8行和第11行我得到了错误:

找不到与匹配的资源 给定名称(在带有值的“标签”处 “@string/app_name”)

找不到与匹配的资源 给定名称(在带有值的“标签”处 “@string/app_name”)


这真的很奇怪,我没有将values文件夹移动到任何地方。

是否检查以确保在res/values/strings.xml中定义了字符串资源

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="de.androidbuch.rechner"
  android:versionCode="1"
  android:versionName="1.0">

  <uses-sdk android:minSdkVersion="7"></uses-sdk>
<application android:icon="@drawable/icon" android:label="@string/app_name"
android:theme="@android:style/Theme.Light">

    <activity android:name=".FormularActivity"
        android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
“我的应用程序”

有时,我注意到,如果有任何.xml文件出错,eclipse也会抛出难以跟踪的错误。我认为解析器恢复得不好,有时您得到的错误可能会产生误导

我也有同样的问题。从
android:label=“@string/app_name”
中删除
“@string”
,它将正常工作

<string name="app_name">"My App"</string>

一个原因可能是,在我的例子中,当您按某种顺序添加和删除项目时,字符串GUI中出现了一个bug

解决方案
只需在xml模式下打开
strings.xml
,而不是GUI,您会发现它不同,并且在其周围或开头粘贴了明显无效的额外文本;虽然在文件
strings.xml
上没有给出错误,但修复它们,然后清理并运行

我的图像也有相同的错误。。只需将扩展名从“.png”重命名为“.jpg”,然后在清理项目并重新编译后,它们就可以正常工作

只需将上面的行“config.xml”添加到内部即可。android平台的底部。工作得很好。几个小时后,我得到了这个解决方案


享受您的编码…

解决方案是确保您的Cordova CLI更新为最新版本,然后启动新应用程序(或重新添加android平台)

然后:

如果您计划使用cordova android 6,则需要对config.xml进行以下更改:

替换此行:

ionic cordova platform rm android
ionic cordova platform add android
<edit-config file="AndroidManifest.xml" mode="merge" target="/manifest/application" xmlns:android="http://schemas.android.com/apk/res/android">

为此:

<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application" xmlns:android="http://schemas.android.com/apk/res/android">
<resource-file src="resources/android/xml/network_security_config.xml" target="app/src/main/res/xml/network_security_config.xml" />

替换此行:

ionic cordova platform rm android
ionic cordova platform add android
<edit-config file="AndroidManifest.xml" mode="merge" target="/manifest/application" xmlns:android="http://schemas.android.com/apk/res/android">

为此:

<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application" xmlns:android="http://schemas.android.com/apk/res/android">
<resource-file src="resources/android/xml/network_security_config.xml" target="app/src/main/res/xml/network_security_config.xml" />


哦,老兄,有时候我真是太蠢了!谢谢!该文件甚至不存在于我的程序中:)该文件也不存在于我的项目中。您能否提供有关如何修复此错误的更多详细信息?我创建了strings.xml并将其放入代码行,很遗憾,代码行本身就给了我一个错误。这个文件还有其他内容吗?这会将活动的标题设置为文字字符串“app_name”,这可能不是任何人想要的。我必须说,答案很糟糕。