2017-05-29 102 views
0

我在使用ConstraintLayout時出現錯誤。錯誤這個樣子的,Android ConstraintLayout未能實例化

Failed to instantiate one or more classes 

The following classes could not be instantiated -android.support.constraint.ConstraintLayout

我已經安裝了這兩個約束佈局Android和求解的約束佈局。

Screenshot of SDK Tools

我有這種相關性在我的應用程序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> 

所以我的問題是,我怎麼能刪除此錯誤?

回答

0

剛剛解決了這個問題FragNav依賴庫導致所有佈局問題,所以我剛剛從gradle文件中刪除了這一行。

compile 'com.ncapdevi:frag-nav:2.0.1'