- 首先,我用的Android 2.3工作室Beta 2的創建具有抽屜式導航活動模板創建一個新的項目。
在content_main.xml文件:錯誤:java.lang.IllegalArgumentException異常:意外的類型標籤67發現
<?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
符號「父」的問題是什麼?
- Sencond,我改變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問題是從哪裏來的。
任何人都可以幫到我嗎?謝謝!
你能發佈完整的錯誤 – Redman
你能顯示你的xml的行號嗎 – Noorul
你的代碼對我來說工作正常。你確定你正確地複製了你的代碼嗎? – Divers