找不到类“android.widget.ThemedSpinnerAdapter”

当我尝试在预先API 21设备上运行我的应用程序时,出现这个奇怪的错误:

I/Choreographer: Skipped 39 frames! The application may be doing too much work on its main thread. 12-10 07:58:44.179 4469-4472/projects.test.com.webviewtest D/dalvikvm: GC_CONCURRENT freed 156K, 4% free 4561K/4744K, paused 4ms+12ms, total 76ms 12-10 07:58:44.409 4469-4469/projects.test.com.webviewtest I/dalvikvm: Could not find method android.widget.Spinner.getPopupContext, referenced from method android.support.v7.widget.AppCompatSpinner.getPopupContext 12-10 07:58:44.409 4469-4469/projects.test.com.webviewtest W/dalvikvm: VFY: unable to resolve virtual method 18719: Landroid/widget/Spinner;.getPopupContext ()Landroid/content/Context; 12-10 07:58:44.409 4469-4469/projects.test.com.webviewtest D/dalvikvm: VFY: replacing opcode 0x6f at 0x000b 12-10 07:58:44.419 4469-4469/projects.test.com.webviewtest I/dalvikvm: Could not find method android.content.Context.getDrawable, referenced from method android.support.v7.widget.AppCompatSpinner.setPopupBackgroundResource 12-10 07:58:44.419 4469-4469/projects.test.com.webviewtest W/dalvikvm: VFY: unable to resolve virtual method 255: Landroid/content/Context;.getDrawable (I)Landroid/graphics/drawable/Drawable; 12-10 07:58:44.419 4469-4469/projects.test.com.webviewtest D/dalvikvm: VFY: replacing opcode 0x6e at 0x0004 12-10 07:58:44.429 4469-4469/projects.test.com.webviewtest I/dalvikvm: Could not find method android.widget.PopupWindow.showAsDropDown, referenced from method android.support.v7.widget.AppCompatPopupWindow.showAsDropDown 12-10 07:58:44.429 4469-4469/projects.test.com.webviewtest W/dalvikvm: VFY: unable to resolve virtual method 18641: Landroid/widget/PopupWindow;.showAsDropDown (Landroid/view/View;III)V 12-10 07:58:44.429 4469-4469/projects.test.com.webviewtest D/dalvikvm: VFY: replacing opcode 0x6f at 0x000d 12-10 07:58:44.459 4469-4469/projects.test.com.webviewtest I/dalvikvm: Could not find method android.widget.CompoundButton.drawableHotspotChanged, referenced from method android.support.v7.widget.SwitchCompat.drawableHotspotChanged 12-10 07:58:44.459 4469-4469/projects.test.com.webviewtest W/dalvikvm: VFY: unable to resolve virtual method 18333: Landroid/widget/CompoundButton;.drawableHotspotChanged (FF)V 12-10 07:58:44.459 4469-4469/projects.test.com.webviewtest D/dalvikvm: VFY: replacing opcode 0x6f at 0x0006 12-10 07:58:44.559 4469-4469/projects.test.com.webviewtest E/dalvikvm: Could not find class 'android.widget.ThemedSpinnerAdapter', referenced from method android.support.v7.widget.AppCompatSpinner$DropDownAdapter.<init> 12-10 07:58:44.569 4469-4469/projects.test.com.webviewtest W/dalvikvm: VFY: unable to resolve instanceof 2184 (Landroid/widget/ThemedSpinnerAdapter;) in Landroid/support/v7/widget/AppCompatSpinner$DropDownAdapter; 12-10 07:58:44.569 4469-4469/projects.test.com.webviewtest D/dalvikvm: VFY: replacing opcode 0x20 at 0x0016 

其实我没有得到一个ANR或不幸的是你的应用程序停止工作,应用程序默默退出到主要活动。

我没有在我的应用程序中使用任何重量级的图像,只是一个四个旋转的页面。

特别是,这一行以红色突出显示:

 E/dalvikvm: Could not find class 'android.widget.ThemedSpinnerAdapter', referenced from method android.support.v7.widget.AppCompatSpinner$DropDownAdapter.<init> 

但是,因为我不使用Eclipse,我相信我有适当的import使用gradle:

 apply plugin: 'com.android.application' android { compileSdkVersion 23 buildToolsVersion "23.0.1" defaultConfig { applicationId "projects.test.com.webviewtest" minSdkVersion 14 targetSdkVersion 23 versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.1.1' compile 'com.android.support:design:23.1.1' compile 'com.android.support:recyclerview-v7:23.1.1' } 

Solutions Collecting From Web of "找不到类“android.widget.ThemedSpinnerAdapter”"

在我的情况下,这是通过在布局XML文件中删除使用android:tint="?attr/colorControlNormal"的…也许这有助于其他人。

我解决了在我的项目中寻找compileSdkVersion的问题。 我有4个模块,其中3个是用sdk编译的,22个是用sdk编译的。

当我把他们全部换成SDK 22后,问题就解决了。 所以我的build议是检查SDK版本,并select项目中的所有模块相同的编号。

干杯

我也遇到了与微调相同的问题,它在某些设备上运行,而不是在某些设备上运行。 因为我把setAdapter(null) 。 因为这是这样的行为。 而不是放在ArrayList arrayList = new ArrayList(); spinner.setAdapter(new ArrayAdapter<String>(activity.this, android.R.layout.simple_dropdown_item_1line, arrayList)); ArrayList arrayList = new ArrayList(); spinner.setAdapter(new ArrayAdapter<String>(activity.this, android.R.layout.simple_dropdown_item_1line, arrayList)); 那么它将在所有设备上工作。