充气类错误ConstraintLayout
我遇到Android Studio问题。我最近升级了我的SDK管理器以包含;充气类错误ConstraintLayout
compile 'com.android.support.constraint:constraint-layout:1.0.0-beta5'
类路径是
classpath 'com.android.tools.build:gradle:2.2.3'
项目构建的罚款。智能感知和文档工作正常。但是,当我尝试运行(在调试中)我的手机上的应用程序时,我得到这个错误;
Caused by: android.view.InflateException: Binary XML file line #2:
Binary XML file line #2: Error inflating class ConstraintLayout
at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:443)
at android.app.Activity.setContentView(Activity.java:2172)
我已经同步了gradle。我已重新启动Android Studio。我清理并重建了这个项目。
有关如何解决此问题的任何想法? 谢谢!
-edit- XML看起来像这样;
<ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/PLAY_PARENT"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/greenfelt2"
android:padding="0dp">
您应该添加如下
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/PLAY_PARENT"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/greenfelt2"
android:padding="0dp">
compile 'com.android.support.constraint:constraint-layout:1.0.2'
有关最新版本检查https://developer.android.com/training/constraint-layout/index.html
这样做会导致此错误; “使用版本1.0.0-beta5时,这个版本的约束库已经过时了,它只是一个该死的intellisense错误,它仍然会建立并运行......(当我看到那个错误时,我甚至没有尝试运行......) 。感谢。 – ausgeorge
查看这个项目更多关于ConstraintLayout https://github.com/Arjun-sna/android-constraintlayout-demo – arjun
如果你有警告,请使用当前版本:'com.android.support.constraint:constraint-布局:1.0.2' – chntgomez
添加XML代码。 –