gpt4 book ai didi

android - R 无法解析为变量,XML 问题?

转载 作者:数据小太阳 更新时间:2023-10-29 02:51:29 26 4
gpt4 key购买 nike

我打开了我的旧项目,它在几个月前工作正常。现在,我几乎在每个 Activity 中都遇到了 eclipse 错误或与错误相关的问题 - R 无法解析为变量

enter image description here

我做了在 stackoverflow 上阅读的所有操作,但还没有任何效果:

  • 进口检查
  • 项目清理

enter image description here

我认为问题可能出在其中一个 XML 文件中,其中还包含 3 个错误,例如 No resource identifier found for attribute "atribute"in package my.package

在此 Activity 中,我使用 Facebook 示例来共享内容。代码:

<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2010-present Facebook.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:facebook="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFF"
>
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFF"
android:id="@+id/activity_share_ui_container">
<com.facebook.widget.LoginButton <!-- 2 errors here --->
android:id="@+id/login_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
facebook:confirm_logout="false"
facebook:fetch_user_info="true"
/>
<LinearLayout
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:orientation="vertical">
<TextView
android:id="@+id/greeting"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_gravity="center"
android:textColor="#333"
android:textSize="18sp"/>
<com.facebook.widget.ProfilePictureView <!-- 1 error here --->
android:id="@+id/profilePicture"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:gravity="center_horizontal"
android:layout_marginBottom="10dp"
facebook:preset_size="normal"/>
<Button
android:id="@+id/postStatusUpdateButton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Post Status Update"
/>
<Button
android:id="@+id/postPhotoButton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Post Photo"
/>
<Button
android:id="@+id/pickFriendsButton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Pick Some Friends"
/>
<Button
android:id="@+id/pickPlaceButton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Pick Place"
/>
</LinearLayout>
</LinearLayout>
<FrameLayout
android:id="@+id/fragment_container"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>

</LinearLayout>

属性有问题: enter image description here

我错过了什么?

最佳答案

您在 xml 文件中使用了 facebook UI 元素。您的 android 项目似乎无法获取 FaceBook SDK 的引用,因为您可能已将其删除或移动到某处。您可以通过以下方式验证它:

在 Project Explore 中右键项目 --> 选择 Properties --> 选择 Android --> 检查是否有正确的 FaceBook SDK 引用。

一旦您提供了正确的引用...构建错误将在清理和构建后消失。

关于android - R 无法解析为变量,XML 问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18699462/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com