2

我必须在 AsynTask 中使用 THREAD_POOL_EXECUTOR,我知道它属于 API 11 及更高版本。用这段代码我检查了它:

                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
                    new init().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
                } else {
                    new init().execute();
                }

但是当我在 2.3 设备中运行我的应用程序时,我收到关于 THREAD_POOL_EXECUTOR 的错误!在上面的代码中我说没有必要在 2.3 设备上运行它!我收到此错误:

10-04 14:00:26.914: W/dalvikvm(728): VFY: unable to resolve static field 33 (THREAD_POOL_EXECUTOR) in Landroid/os/AsyncTask;

那是什么?我该如何解决?

更新:整个logcat:

10-04 16:27:50.254: D/dalvikvm(760): DexOpt: couldn't find static field
10-04 16:27:50.254: W/dalvikvm(760): VFY: unable to resolve static field 33 (THREAD_POOL_EXECUTOR) in Landroid/os/AsyncTask;
10-04 16:27:50.254: D/dalvikvm(760): VFY: replacing opcode 0x62 at 0x000d
10-04 16:27:50.254: D/dalvikvm(760): VFY: dead code 0x000f-0014 in Lcom/app/weatherclock/MainActivity$10;.run ()V

10-04 16:27:51.124: D/dalvikvm(760): GC_CONCURRENT freed 174K, 45% free 3217K/5831K, external 1608K/2119K, paused 7ms+6ms
10-04 16:27:51.234: W/webcore(760): Can't get the viewWidth after the first layout
10-04 16:27:51.244: W/dalvikvm(760): JNI WARNING: jarray 0x40556118 points to non-array object (Ljava/lang/String;)
10-04 16:27:51.254: I/dalvikvm(760): "WebViewCoreThread" prio=5 tid=9 NATIVE
10-04 16:27:51.254: I/dalvikvm(760):   | group="main" sCount=0 dsCount=0 obj=0x4050d6b0 self=0x216c78
10-04 16:27:51.254: I/dalvikvm(760):   | sysTid=768 nice=0 sched=0/0 cgrp=default handle=2190768
10-04 16:27:51.254: I/dalvikvm(760):   | schedstat=( 339530872 394652888 76 )
10-04 16:27:51.254: I/dalvikvm(760):   at android.webkit.LoadListener.nativeFinished(Native Method)
10-04 16:27:51.264: I/dalvikvm(760):   at android.webkit.LoadListener.nativeFinished(Native Method)
10-04 16:27:51.264: I/dalvikvm(760):   at android.webkit.LoadListener.tearDown(LoadListener.java:1200)
10-04 16:27:51.264: I/dalvikvm(760):   at android.webkit.LoadListener.handleEndData(LoadListener.java:721)
10-04 16:27:51.264: I/dalvikvm(760):   at android.webkit.LoadListener.handleMessage(LoadListener.java:219)
10-04 16:27:51.264: I/dalvikvm(760):   at android.os.Handler.dispatchMessage(Handler.java:99)
10-04 16:27:51.264: I/dalvikvm(760):   at android.os.Looper.loop(Looper.java:130)
10-04 16:27:51.264: I/dalvikvm(760):   at android.webkit.WebViewCore$WebCoreThread.run(WebViewCore.java:629)
10-04 16:27:51.264: I/dalvikvm(760):   at java.lang.Thread.run(Thread.java:1019)
10-04 16:27:51.274: E/dalvikvm(760): VM aborting
4

1 回答 1

2

这只是一个警告,您可以忽略它。

Dalvik 类加载器找到了对缺失字段的引用并发出警告。上面的SDK_INT条件阻止了这部分代码在 pre-Honeycomb 上运行。

HONEYCOMB常量是static final在编译时内联的原语,不需要在类加载时解析。)

于 2013-10-04T13:32:21.027 回答