2017-03-08 93 views
2

我試圖自己解決這個問題,但我不能得到一個解決方案。 在stackoverflow上有類似的問題,但沒有答案幫助我(Cannot instantiate class android.support.v7.widget.SearchView)。錯誤膨脹類android.support.v7.widget.SearchView

該搜索在另一個應用程序中完美。當我嘗試在另一個項目中實現它時出現問題。

這是我得到的錯誤。

android.view.InflateException:二進制XML文件的第10行:二進制XML文件的第10行錯誤:充氣類android.support.v7.widget.SearchView

這是我的.xml。 (在LinearLayout中)

<android.support.v7.widget.SearchView 
    android:id="@+id/floating_search_view" 
    android:layout_width="match_parent" 
    android:layout_height="50dp" 
    app:iconifiedByDefault="false" 
    app:actionViewClass="android.support.v7.widget.SearchView" 
    /> 

<ListView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/list" 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:drawSelectorOnTop="true"/> 

在下面有我的清單

<activity android:name=".robodex.Robodex" 
     android:label="Robodex" 
     android:launchMode="singleTop" 
     > 
     <intent-filter> 
      <action android:name="android.intent.action.SEARCH" /> 
     </intent-filter> 
     <meta-data android:name="android.app.searchable" 
      android:resource="@xml/searchable"/> 
    </activity> 

而這裏所有的依賴的一部分

android { 
compileSdkVersion 24 
buildToolsVersion "25.0.0" 
defaultConfig { 
    applicationId "it.uniroma1.android" 
    minSdkVersion 21 
    targetSdkVersion 24 
    versionCode 1 
    versionName "1.0" 
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 
} 
buildTypes { 
    release { 
     minifyEnabled false 
     proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
    } 
} 

dependencies { 
compile fileTree(dir: 'libs', include: ['*.jar']) 
compile 'com.android.support:appcompat-v7:24.2.1' 
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha9' 
testCompile 'junit:junit:4.12' 
compile files('libs/pocketsphinx-android-5prealpha-nolib.jar') 
compile files('libs/YouTubeAndroidPlayerApi.jar') 
compile 'com.android.support:design:24.2.1' 
compile 'com.android.support:support-v4:24.2.1' 
compile 'com.github.arimorty:floatingsearchview:2.0.3' 
} 
+0

它似乎問題不在我們的發佈代碼。我試過了。它運作良好。 –

回答

0

設置你的buildToolsVersion到24.0.2在您的build.gradle然後看看。

相關問題