2017-03-08 90 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然后看看。

相关问题