在撤消"之后,IllegalArgumentException和"线程仍然被挂起返回空SQLite游标后

时间:2014-03-13 13:32:31

标签: android sqlite dalvik

运行我的Android应用程序时,ContentProvider返回一个空的SQLite游标(零行)。这导致dalvikvm在LogCat中输出以下消息:

threadid=1 still suspended after undo (sc=1 dc=1)

Eclipse中的调试选项卡显示以下异常:

Thread [<1> main] (Suspended (exception IllegalArgumentException))  
    <VM does not provide monitor information>   
    AsyncTaskLoader$LoadTask.onPostExecute(Object) line: 63 
    AsyncTaskLoader$LoadTask(ModernAsyncTask).finish(Object) line: 461  
    ModernAsyncTask.access$500(ModernAsyncTask, Object) line: 47    
    ModernAsyncTask$InternalHandler.handleMessage(Message) line: 474    
    ModernAsyncTask$InternalHandler(Handler).dispatchMessage(Message) line: 99  
    Looper.loop() line: 213 
    ActivityThread.main(String[]) line: 5225    
    Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]  
    Method.invoke(Object, Object...) line: 525  
    ZygoteInit$MethodAndArgsCaller.run() line: 741  
    ZygoteInit.main(String[]) line: 557 
    NativeStart.main(String[]) line: not available [native method]

我已记录OffersDatabaseHelper.OffersDatabaseHelper课程中的所有操作。方法query将光标返回到android.content.ContentProvider方法query,这似乎是导致问题的原因。

LogCat输出:

03-13 14:12:20.116: I/System.out(2521): Sending WAIT chunk
03-13 14:12:20.116: I/dalvikvm(2521): Debugger is active
03-13 14:12:20.316: I/System.out(2521): Debugger has connected
03-13 14:12:20.316: I/System.out(2521): waiting for debugger to settle...
03-13 14:12:20.516: I/System.out(2521): waiting for debugger to settle...
03-13 14:12:20.716: I/System.out(2521): waiting for debugger to settle...
03-13 14:12:20.916: I/System.out(2521): waiting for debugger to settle...
03-13 14:12:21.117: I/System.out(2521): waiting for debugger to settle...
03-13 14:12:21.317: I/System.out(2521): waiting for debugger to settle...
03-13 14:12:21.517: I/System.out(2521): debugger has settled (1311)
03-13 14:12:21.537: V/OffersContentProvider(2521): onCreate called
03-13 14:12:21.537: I/OffersContentProvider(2521): setting context
03-13 14:12:21.537: I/OffersContentProvider(2521): setting dbHelper
03-13 14:12:21.537: I/OffersContentProvider(2521): initiating OffersDatabaseHelper
03-13 14:12:21.537: V/OffersContentProvider(2521): OffersDatabaseHelper.OffersDatabaseHelper called
03-13 14:12:21.557: I/OffersContentProvider(2521): Returning if offersDB is null
03-13 14:12:21.557: D/OffersContentProvider(2521): false
03-13 14:12:21.937: V/OffersContentProvider(2521): query called
03-13 14:12:21.977: I/OffersContentProvider(2521): CallerClassName=android.content.ContentProvider , Caller method name: query
03-13 14:12:21.987: I/OffersContentProvider(2521): Callee method name: query
03-13 14:12:21.987: D/OffersContentProvider - query - uri(2521): content://com.example.provider.offers/offers
03-13 14:12:21.997: D/OffersContentProvider - query - projection(2521): [offer_id, offer_title, offer_description, offer_distance, offer_icon, offer_reference]
03-13 14:12:22.007: D/OffersContentProvider - query - selection(2521): null
03-13 14:12:22.007: D/OffersContentProvider - query - selectionArgs(2521): null
03-13 14:12:22.007: D/OffersContentProvider - query - sort(2521): null
03-13 14:12:22.007: I/OffersContentProvider(2521): Instantiating SQLiteQueryBuilder with table offers
03-13 14:12:22.017: I/OffersContentProvider(2521): Instantiating SQLIteQueryBuilder succesful
03-13 14:12:22.017: I/OffersContentProvider(2521): Trying to match uri with 2
03-13 14:12:22.027: I/OffersContentProvider(2521): Could not match with uri
03-13 14:12:22.027: D/OffersContentProvider(2521): 1
03-13 14:12:22.027: I/OffersContentProvider(2521): Preparing orderBy
03-13 14:12:22.027: I/OffersContentProvider(2521): sort is empty, orderBy will be offer_distance ASC
03-13 14:12:22.027: I/OffersContentProvider(2521): Preparing to query the underlying database
03-13 14:12:22.027: D/libEGL(2521): loaded /vendor/lib/egl/libEGL_adreno.so
03-13 14:12:22.027: D/libEGL(2521): loaded /vendor/lib/egl/libGLESv1_CM_adreno.so
03-13 14:12:22.027: I/OffersContentProvider(2521): Querying underlying database successful
03-13 14:12:22.038: I/OffersContentProvider(2521): Dumping cursor
03-13 14:12:22.038: D/libEGL(2521): loaded /vendor/lib/egl/libGLESv2_adreno.so
03-13 14:12:22.038: D/OffersContentProvider(2521): android.database.sqlite.SQLiteCursor@41b8afa0
03-13 14:12:22.038: I/Adreno-EGL(2521): <qeglDrvAPI_eglInitialize:316>: EGL 1.4 QUALCOMM build:  (CL4169980)
03-13 14:12:22.038: I/Adreno-EGL(2521): OpenGL ES Shader Compiler Version: 17.01.10.SPL
03-13 14:12:22.038: I/Adreno-EGL(2521): Build Date: 12/01/13 Sun
03-13 14:12:22.038: I/Adreno-EGL(2521): Local Branch: 
03-13 14:12:22.038: I/Adreno-EGL(2521): Remote Branch: 
03-13 14:12:22.038: I/Adreno-EGL(2521): Local Patches: 
03-13 14:12:22.038: I/Adreno-EGL(2521): Reconstruct Branch: 
03-13 14:12:22.038: D/OffersContentProvider(2521): Cursor has 0 rows
03-13 14:12:22.038: I/OffersContentProvider(2521): Returing cursor
03-13 14:12:22.078: D/OpenGLRenderer(2521): Enabling debug mode 0
03-13 14:12:23.069: D/dalvikvm(2521): threadid=1: still suspended after undo (sc=1 dc=1)

杂项细节:

  • 虚拟设备和使用
  • 进行测试的Sony Xperia Z I都会出现此问题
  • Android min-sdk = 11,target-sdk = 19

关于如何解决这个问题的任何意见都非常欢迎,谢谢你。

1 个答案:

答案 0 :(得分:0)

继续挖掘后,我刚刚发现了这个特殊问题的原因。调试器显示SQLite给了我一个例外,告诉我字段_id不存在,因为我的主键不是_id,所以我感到非常惊讶。

感谢Al Sutton's answer在另一个问题上,我发现我的表格中的主要字段与SQLiteOpenHelper要求的字段不同/

将主要字段更改为_id解决了我的问题。