2017-01-16 6 views
2
  • Во-первых, я использовал Android Studio 2.3 Beta 2 создать новый проект с Navigation Выдвижные активность шаблона.

В 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> 

enter image description here

Был ошибка:

Cannot resolve symbol 'parent' 

ПОЛНЫЙ LOG:

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, несмотря на ошибку ниже (вторая линия), 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 пришел.

Кто-нибудь может мне помочь? Благодаря!

+0

Вы можете указать полную ошибку – Redman

+0

можете ли вы показать номер строки вашего xml's – Noorul

+0

Ваш код работает нормально для меня. Вы уверены, что скопировали свой код правильно? – Divers

ответ

3

Я думаю, вы можете использовать старую версию ConstraintLayout. Обязательно используйте последнюю версию - бета-версию 4 или новее (мы представили поддержку родительского тега в ограничении альфа-5 ...).

+0

** 1.0.0-alpha4 ** - это новейшая версия ** ConstraintLayout **, проверьте https://bintray.com/ligboy/ maven/constraint-layout –

+0

Ну :-) Я могу заверить, что альфа-4 - это не самая новая версия ConstraintLayout. Проверьте http://tools.android.com/recent/constraintlayoutbeta4isnowavailable. Вы должны получить официальную версию от менеджера SDK, а не от bintray - я не знаю, кто это сделал. –

+0

О, да, кто-то это сделал, но А.С. действительно ссылался на свою библиотеку на первом месте, это странно. Я обновлю его и повторю попытку. Спасибо @Nicolas Roard –