Android ConstraintLayout 实例化失败
Android ConstraintLayout failed to instantiated
我在使用 ConstraintLayout 时遇到错误。错误看起来像这样,
Failed to instantiate one or more classes
The following classes could not be instantiated
-android.support.constraint.ConstraintLayout
我已经安装了 android 的约束布局和约束布局的求解器。
我的应用程序中有此依赖项gradle 文件:build.gradle
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
//butterknife for view binding
compile 'com.jakewharton:butterknife:8.6.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.6.0'
//bottom bar navigation
compile 'com.roughike:bottom-bar:2.3.1'
//fragment managment library
compile 'com.ncapdevi:frag-nav:2.0.1'
//for ripple animation
compile 'com.balysv:material-ripple:1.0.2'
testCompile 'junit:junit:4.12'
我的 XML 布局是这样的 -
<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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.cr.priyankjain.customrom.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>
所以我的问题是如何消除此错误?
刚刚解决了这个 FragNav 依赖库导致所有布局问题的问题,所以我刚刚从 gradle 文件中删除了这一行。
compile 'com.ncapdevi:frag-nav:2.0.1'
我在使用 ConstraintLayout 时遇到错误。错误看起来像这样,
Failed to instantiate one or more classes
The following classes could not be instantiated
-android.support.constraint.ConstraintLayout
我已经安装了 android 的约束布局和约束布局的求解器。
我的应用程序中有此依赖项gradle 文件:build.gradle
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
//butterknife for view binding
compile 'com.jakewharton:butterknife:8.6.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.6.0'
//bottom bar navigation
compile 'com.roughike:bottom-bar:2.3.1'
//fragment managment library
compile 'com.ncapdevi:frag-nav:2.0.1'
//for ripple animation
compile 'com.balysv:material-ripple:1.0.2'
testCompile 'junit:junit:4.12'
我的 XML 布局是这样的 -
<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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.cr.priyankjain.customrom.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>
所以我的问题是如何消除此错误?
刚刚解决了这个 FragNav 依赖库导致所有布局问题的问题,所以我刚刚从 gradle 文件中删除了这一行。
compile 'com.ncapdevi:frag-nav:2.0.1'