Java Can';t编译代码错误:未找到与给定名称匹配的资源
当我试图编译代码时,我目前在代码中有多个错误,我无法找出哪里出错了 我遇到的错误包括:Java Can';t编译代码错误:未找到与给定名称匹配的资源,java,android,android-studio,Java,Android,Android Studio,当我试图编译代码时,我目前在代码中有多个错误,我无法找出哪里出错了 我遇到的错误包括: C:\Users\Jamie\AndroidStudioProjects\lifeWithASD\app\build\intermediates\manifests\ full\debug\AndroidManifest.xml Error:(14, 24) No resource found that matches the given name (at 'label' with value '@str
C:\Users\Jamie\AndroidStudioProjects\lifeWithASD\app\build\intermediates\manifests\
full\debug\AndroidManifest.xml
Error:(14, 24) No resource found that matches the given name
(at 'label' with value '@string/app_name').
Error:(18, 28) No resource found that matches the given name
(at 'label' with value '@string/app_name').
Error:Execution failed for task ':app:processDebugResources'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException:
Process 'command 'C:\Users\Jamie\AppData\Local\Android\sdk3\build-tools\22.0.1\aapt.exe''
finished with non-zero exit value 1
我不知道为什么在编译时会出现这些错误,因为我不知道
@string/app name
在代码中指的是什么。因此,如果您从第14行的开始处打开AndroidManifest.xml
,在第24行的结束处打开android:label,您需要确保您有一个名为android:label的属性=“@string/app_name”
如果你有,那么你需要在AppPath/res/values
中打开strings.xml
并创建一个名为app_name的字符串资源
错误的第二部分也是同样的问题
要将字符串添加到xml文件中,请执行以下操作:
<string name="app_name">YourApplicationNameHere</string>
YourApplicationName此处
我现在在将按钮链接到新页面时遇到了一个问题:public void Parents(View v){button button=(button)v;startActivity(new Intent(getApplicationContext(),ParentPage.class));}我无法确定这段代码是否会链接到新的活动页面。如果它修复了错误,然后选择它作为正确答案。这样,任何遇到这个问题的人都知道它修复了问题。@Jamax91x为什么要在“单击侦听器”中实例化按钮?我刚刚学习了youtube教程,这就是这个人所做的id。我是使用android studio的新手。我不知道如何更正此问题。按钮的XML代码:如果您所做的只是实例化按钮,则不需要该行代码。有关启动其他活动的问题,请查看以下链接: