【问题标题】:How do I remove the multiple "Attribute not allowed here error" when I start a new document?启动新文档时如何删除多个“此处不允许属性错误”?
【发布时间】:2019-12-30 11:55:53
【问题描述】:

我是 Android 开发的新手,我正在尝试制作一张简单的生日快乐卡。每当我启动应用程序并创建一个新项目时,我都会在 Activity_Main.xml 文件中收到一些错误,导致我无法看到预览。

我尝试过重新安装 Java、重新安装 Android Studio、检查代理、将布局从约束更改为相对以及打开和关闭 XML 文件。

<RelativeLayout xmlns:android="schemas.android.com/apk/res/android"
   xmlns:tools="schemas.android.com/tools"
   android:layout_height="match_parent"
   android:layout_width="match_parent"
   tools:context=".MainActivity">
     <TextView
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:text="Happy Birthday YOURFRIENDHERE" />
</RelativeLayout>

给出的代码只是在手机屏幕上显示文本,但是我一直收到所有属性的错误,Android:layout、Tools:context 和 TextView 说它们是不允许的。即使我创建了一个新项目并且没有编辑任何内容,我仍然会在自动填充的代码上遇到错误。

【问题讨论】:

  • schemas.android.com/apk/res/android" xmlns:tools="schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity" > 完整代码
  • 不要在评论中发布您的附加代码/XML,编辑您的问题并将其添加到那里。此外,请准确指定您收到的错误类型。您是否尝试过构建/运行您的项目?

标签: java android android-studio kotlin


【解决方案1】:

试试这个

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_height="match_parent"
    android:layout_width="match_parent"
    tools:context=".MainActivity">
    <TextView
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:text="Happy Birthday YOURFRIENDHERE" />
</RelativeLayout>

【讨论】:

  • 这仍然不起作用,我设法看到 Gradle 无法连接,我尝试手动安装 Gradle 并创建路径,我可以验证 Gradle 是否在 CMD 中运行但是我' m 仍然无法通过 Android Studio 连接到 Gradle。
【解决方案2】:

这是一个 VPN 问题,没有从谷歌收到某些文件,因此没有访问必要的文件。现在一切正常!

【讨论】:

    【解决方案3】:

    我认为这是因为您的 android studio 版本不是最新的,因为我认为当您发现您阻止从下载 gradle 资源时,谷歌希望我们使用最新版本通过你的安卓工作室上网。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-04-15
      • 2020-09-20
      • 2020-03-31
      • 2018-08-08
      • 1970-01-01
      • 2014-01-10
      • 2015-10-19
      相关资源
      最近更新 更多