簡體   English   中英

錯誤:java.lang.IllegalArgumentException:發現意外的類型標記 67

[英]Error:java.lang.IllegalArgumentException: Unexpected type tag 67 found

  • 首先,我使用Android Studio 2.3 Beta 2創建一個帶有Navigation Drawer Activity模板的新項目。

content_main.xml文件中:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:showIn="@layout/app_bar_main"
    tools:context="com.waylanpunch.event.MainActivity">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</android.support.constraint.ConstraintLayout>

在此處輸入圖片說明

有一個錯誤:

Cannot resolve symbol 'parent'

完整日志:

Information:Gradle tasks [:app:assembleDebug]
D:\WORKGROUP\WORKSPACES\Android_Studio_WORKSPACE\Event\app\src\main\res\layout\content_main.xml
Error:(16, 49) String types not allowed (at 'layout_constraintBottom_toBottomOf' with value 'parent').
Error:(17, 45) String types not allowed (at 'layout_constraintLeft_toLeftOf' with value 'parent').
Error:(18, 47) String types not allowed (at 'layout_constraintRight_toRightOf' with value 'parent').
Error:(19, 43) String types not allowed (at 'layout_constraintTop_toTopOf' with value 'parent').
D:\WORKGROUP\WORKSPACES\Android_Studio_WORKSPACE\Event\app\build\intermediates\res\merged\debug\layout\content_main.xml
Error:(16, 49) String types not allowed (at 'layout_constraintBottom_toBottomOf' with value 'parent').
Error:(17, 45) String types not allowed (at 'layout_constraintLeft_toLeftOf' with value 'parent').
Error:(18, 47) String types not allowed (at 'layout_constraintRight_toRightOf' with value 'parent').
Error:(19, 43) String types not allowed (at 'layout_constraintTop_toTopOf' with value 'parent').
Error:Execution failed for task ':app:processDebugResources'.
> com.android.ide.common.process.ProcessException: Failed to execute aapt
Information:BUILD FAILED
Information:Total time: 1.786 secs
Information:9 errors
Information:0 warnings
Information:See complete output in console

符號“父母”有什么問題?

  • 其次,我將 ConstraintLayout 更改為 Framelayout

content_main.xml文件中:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:showIn="@layout/app_bar_main"
    tools:context="com.waylanpunch.event.MainActivity">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:text="Hello World!" />

</FrameLayout>

BUILD的過程中,盡管出現了下面的錯誤(第 2 行),但BUILD是成功的。

Information:Gradle tasks [:app:generateDebugSources,:app:generateDebugAndroidTestSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies]
Error:java.lang.IllegalArgumentException: Unexpected type tag 67 found.
Information:BUILD SUCCESSFUL
Information:Total time: 2.523 secs
Information:1 error
Information:0 warnings
Information:See complete output in console

而且我不知道IllegalArgumentException問題從何而來。

任何人都可以幫助我嗎? 謝謝!

我認為您可能正在使用舊版本的 ConstraintLayout。 請務必使用最新版本——beta 4 或更新版本(我們在constraintlayout alpha 5 中引入了父標簽支持...)。

我可以通過重新啟動 Android Studio 來解決類似的問題。

這是我的條件。 我對 .java 文件而不是 .xml 文件做了一些更改然后突然當我構建項目時,我總是收到以下消息

Error:java.lang.IllegalArgumentException: Unexpected type tag 67 found.

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM