在Android Studio中夸大ConstraintLayout的错误 [英] error inflating ConstraintLayout in android studio
问题描述
我在使用Android Studio时遇到问题.我最近升级了我的SDK Manager,使其包含;
I'm having problems with Android Studio. I recently upgraded my SDK Manager to include;
compile 'com.android.support.constraint:constraint-layout:1.0.0-beta5'
classpath是
classpath is
classpath 'com.android.tools.build:gradle:2.2.3'
项目构建良好. Intellisense和文档工作正常.但是当我尝试在手机上运行(调试)该应用程序时,出现此错误;
Project builds fine. Intellisense and documentation works fine. But when I try to run (in debug) the app on my phone I get this error;
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.我已经清理并重建了项目.
I've synced gradle. I've restarted Android Studio. I've cleaned and rebuilt the project.
关于如何解决此问题的任何想法? 谢谢!
Any ideas on how to fix this? thanks!
-编辑- XML看起来像这样;
-edit- XML looks like this;
<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'
有关最新版本,请在此处查看
更新
对于那些从android支持切换到androidx
的用户,请记住将android.support.constraint.ConstraintLayout
更改为androidx.constraintlayout.widget.ConstraintLayout
For those who are switching from android support to androidx
, remember to change android.support.constraint.ConstraintLayout
to androidx.constraintlayout.widget.ConstraintLayout
这篇关于在Android Studio中夸大ConstraintLayout的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!