当我尝试在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,我确信我使用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'
}
答案 0 :(得分:5)
在我的情况下,通过在布局XML文件中删除{{1}}的使用来解决这个问题......也许这有助于其他人。
答案 1 :(得分:1)
我在项目中解决了查找compileSdkVersion的问题。 我有4个模块,其中3个用sdk 22编译,一个用sdk 23编译。
在我将所有这些内容更改为sdk 22后,问题解决了。所以我的建议是检查SDK版本,并为项目中的所有模块选择相同的编号。
干杯
答案 2 :(得分:1)
我也遇到了与微调器相同的问题,它在某些设备上运行而在某些设备上没有运行。因为我放了setAdapter(null)
。因此,它表现得像这样。而不是放ArrayList arrayList = new ArrayList();
spinner.setAdapter(new ArrayAdapter<String>(activity.this, android.R.layout.simple_dropdown_item_1line, arrayList));
然后它将适用于所有设备。
答案 3 :(得分:0)
在您的layout.xml中添加以下内容。...
# xmlns:app="http://schemas.android.com/apk/res-auto"
确保在将listnerEvents设置为微调器的末尾,将数组列表设置为微调器,
快乐的编码.....