Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

升级到 Android 10,后调用Matisse崩溃 : Invalid column COUNT(*) AS count #659

Open
JakePrim opened this issue Sep 4, 2019 · 17 comments
Labels

Comments

@JakePrim
Copy link

JakePrim commented Sep 4, 2019

Describe the bug
升级到 Android 10,后调用Matisse崩溃
Invalid column COUNT(*) AS count
To Reproduce
Caused by: java.lang.IllegalArgumentException: Invalid column COUNT(*) AS count at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:170) at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:140) at android.content.ContentProviderProxy.query(ContentProviderNative.java:423) at android.content.ContentResolver.query(ContentResolver.java:944) at android.content.ContentResolver.query(ContentResolver.java:880) at androidx.core.content.ContentResolverCompat.query(ContentResolverCompat.java:81) at androidx.loader.content.CursorLoader.loadInBackground(CursorLoader.java:63) at com.zhihu.matisse.internal.loader.AlbumLoader.loadInBackground(AlbumLoader.java:114) at com.zhihu.matisse.internal.loader.AlbumLoader.loadInBackground(AlbumLoader.java:33) at androidx.loader.content.AsyncTaskLoader.onLoadInBackground(AsyncTaskLoader.java:307) at androidx.loader.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:60) at androidx.loader.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:48) at androidx.loader.content.ModernAsyncTask$2.call(ModernAsyncTask.java:141) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)  at java.lang.Thread.run(Thread.java:919) 
Expected behavior

Screenshots
image
Smartphone (please complete the following information):

  • Device: [e.g. Pixel 3 XL]
  • OS: [e.g. Android 29]
  • Version [29]
@REBOOTERS REBOOTERS added the bug label Sep 4, 2019
@REBOOTERS
Copy link
Contributor

还没有适配 Android 10 ,近期会支持一下。

@vee-zhang
Copy link

我也遇到了

@yccheok
Copy link
Contributor

yccheok commented Sep 11, 2019

Just an additional note to all, if you intent to reproduce this problem in Android Q, which introduces scoped storage recently, you need to change Matisse library and Matisse sample's build.gradle, to both

compileSdkVersion 29 and targetSdkVersion 29

AlbumLoader.java
My initial testing is that, Android Q is having problem in

  1. Using "COUNT(*) AS " + COLUMN_COUNT in PROJECTION
  2. Using GROUP BY in SELECTION

An op seem to have solution on these limitations - #646 However, the code formatting make it difficult to copy and paste directly for testing purpose. I may need to spend some time, to digest the idea behind the code as I'm not familiar with CursorLoader.

@yccheok
Copy link
Contributor

yccheok commented Sep 11, 2019

同志好!

我尝试修复 Android Q 的臭虫。因为我对 CursorLoader 并不了解。如果你能找出更好的方案,请修正。

谢谢同志们!

这是我建议的代码

2c8f6f8

MediaStore.MediaColumns.DATA 已经 deprecated 了。可,我不知道应该用什么代替品。请同志留意 - https://stackoverflow.com/questions/57893449/what-is-the-replacement-for-deprecated-mediastore-mediacolumns-data-in-android-q

@yccheok
Copy link
Contributor

yccheok commented Sep 11, 2019

因为 MediaStore.MediaColumns.DATA 已经 deprecated ,我建议把 AlbummCoverPath 转换成 mCoverUri

我比较不确定的是,会不会在一些刁钻的状况,Uri.toString / Uri.parse 的相互转换会失败?

@JocelynDavid
Copy link

I got the same crash on version 0.5.3-beta2, any idea when a fix will be added to the library?

@REBOOTERS
Copy link
Contributor

近期工作中的事情比较多,会抽空进行适配。

@Jocerly
Copy link

Jocerly commented Oct 14, 2019

可以暂时按照 issues 646 来改

@kilo-swodh
Copy link

希望尽快适配Android 10

@REBOOTERS
Copy link
Contributor

希望尽快适配Android 10

https://github.com/zhihu/Matisse/releases/tag/v0.5.3-beta3 已经适配了呀。

@kilo-swodh
Copy link

希望尽快适配Android 10

https://github.com/zhihu/Matisse/releases/tag/v0.5.3-beta3 已经适配了呀。

抱歉,已发现是我这边没适配好Android 10的外部存储限制

@wlong800
Copy link

api 'com.zhihu.android:matisse:0.5.3-beta3'
为啥编译不过

ERROR: Unable to resolve dependency for ':PhotoSdk@debug/compileClasspath': Could not download matisse.aar (com.zhihu.android:matisse:0.5.3-beta3)
Show Details
Affected Modules: PhotoSdk

ERROR: Unable to resolve dependency for ':PhotoSdk@debugAndroidTest/compileClasspath': Could not download matisse.aar (com.zhihu.android:matisse:0.5.3-beta3)
Show Details
Affected Modules: PhotoSdk

ERROR: Unable to resolve dependency for ':PhotoSdk@debugUnitTest/compileClasspath': Could not download matisse.aar (com.zhihu.android:matisse:0.5.3-beta3)
Show Details
Affected Modules: PhotoSdk

ERROR: Unable to resolve dependency for ':PhotoSdk@release/compileClasspath': Could not download matisse.aar (com.zhihu.android:matisse:0.5.3-beta3)
Show Details
Affected Modules: PhotoSdk

ERROR: Unable to resolve dependency for ':PhotoSdk@releaseUnitTest/compileClasspath': Could not download matisse.aar (com.zhihu.android:matisse:0.5.3-beta3)
Show Details
Affected Modules: PhotoSdk

ERROR: Unable to resolve dependency for ':App@debug/compileClasspath': Could not download matisse.aar (com.zhihu.android:matisse:0.5.3-beta3)
Show Details
Affected Modules: App

ERROR: Unable to resolve dependency for ':App@debugAndroidTest/compileClasspath': Could not download matisse.aar (com.zhihu.android:matisse:0.5.3-beta3)
Show Details
Affected Modules: App

ERROR: Unable to resolve dependency for ':App@debugUnitTest/compileClasspath': Could not download matisse.aar (com.zhihu.android:matisse:0.5.3-beta3)
Show Details
Affected Modules: App

ERROR: Unable to resolve dependency for ':App@release/compileClasspath': Could not download matisse.aar (com.zhihu.android:matisse:0.5.3-beta3)
Show Details
Affected Modules: App

ERROR: Unable to resolve dependency for ':App@releaseUnitTest/compileClasspath': Could not download matisse.aar (com.zhihu.android:matisse:0.5.3-beta3)
Show Details
Affected Modules: App

@wlong800
Copy link

@JakePrim kilo-swodh

moodcal pushed a commit to moodcal/Matisse that referenced this issue Mar 7, 2020
@serreau
Copy link

serreau commented Mar 26, 2020

Same problem with Android 10 (pixel 4)

2020-03-26 20:32:13.820 1815-2067/[my project name] E/AndroidRuntime: FATAL EXCEPTION: ModernAsyncTask #1
Process: [my project name] , PID: 1815
java.lang.RuntimeException: An error occurred while executing doInBackground()
at androidx.loader.content.ModernAsyncTask$3.done(ModernAsyncTask.java:164)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
at java.util.concurrent.FutureTask.run(FutureTask.java:271)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:919)
Caused by: java.lang.IllegalArgumentException: Invalid column COUNT(*) AS count
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:170)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:140)
at android.content.ContentProviderProxy.query(ContentProviderNative.java:423)
at android.content.ContentResolver.query(ContentResolver.java:944)
at android.content.ContentResolver.query(ContentResolver.java:880)
at androidx.core.content.ContentResolverCompat.query(ContentResolverCompat.java:81)
at androidx.loader.content.CursorLoader.loadInBackground(CursorLoader.java:63)
at com.zhihu.matisse.internal.loader.AlbumLoader.loadInBackground(AlbumLoader.java:97)
at com.zhihu.matisse.internal.loader.AlbumLoader.loadInBackground(AlbumLoader.java:33)
at androidx.loader.content.AsyncTaskLoader.onLoadInBackground(AsyncTaskLoader.java:307)
at androidx.loader.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:60)
at androidx.loader.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:48)
at androidx.loader.content.ModernAsyncTask$2.call(ModernAsyncTask.java:141)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 
at java.lang.Thread.run(Thread.java:919) 

@baizhu0414
Copy link

baizhu0414 commented May 6, 2021

我遇到了类似的问题:(已经调整编译环境到buildVersion29)
2021-05-06 19:33:13.231 5150-5239/com.example.testmatisse E/AndroidRuntime: FATAL EXCEPTION: ModernAsyncTask #1
Process: com.example.testmatisse, PID: 5150
java.lang.RuntimeException: An error occurred while executing doInBackground()
at androidx.loader.content.ModernAsyncTask$3.done(ModernAsyncTask.java:164)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
at java.util.concurrent.FutureTask.run(FutureTask.java:271)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:919)
Caused by: java.lang.IllegalArgumentException: Invalid column COUNT(*) AS count
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:170)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:140)
at android.content.ContentProviderProxy.query(ContentProviderNative.java:423)
at android.content.ContentResolver.query(ContentResolver.java:946)
at android.content.ContentResolver.query(ContentResolver.java:881)
at androidx.core.content.ContentResolverCompat.query(ContentResolverCompat.java:81)
at androidx.loader.content.CursorLoader.loadInBackground(CursorLoader.java:63)
at com.zhihu.matisse.internal.loader.AlbumLoader.loadInBackground(AlbumLoader.java:97)
at com.zhihu.matisse.internal.loader.AlbumLoader.loadInBackground(AlbumLoader.java:33)
at androidx.loader.content.AsyncTaskLoader.onLoadInBackground(AsyncTaskLoader.java:307)
at androidx.loader.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:60)
at androidx.loader.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:48)
at androidx.loader.content.ModernAsyncTask$2.call(ModernAsyncTask.java:141)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 
at java.lang.Thread.run(Thread.java:919) 

compileSdkVersion 29
defaultConfig { applicationId 'com.example.testmatisse' minSdkVersion 14 targetSdkVersion 29 versionCode 1 versionName "1.0" }

另外,我运行Demo时没有出问题,但是我已经基本保持和Demo一致的环境了,唯一不同就是依赖方式了。

@baizhu0414
Copy link

baizhu0414 commented May 7, 2021

我遇到了类似的问题:(已经调整编译环境到buildVersion29)
2021-05-06 19:33:13.231 5150-5239/com.example.testmatisse E/AndroidRuntime: FATAL EXCEPTION: ModernAsyncTask #1
Process: com.example.testmatisse, PID: 5150
java.lang.RuntimeException: An error occurred while executing doInBackground()
at androidx.loader.content.ModernAsyncTask$3.done(ModernAsyncTask.java:164)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
at java.util.concurrent.FutureTask.run(FutureTask.java:271)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:919)
Caused by: java.lang.IllegalArgumentException: Invalid column COUNT(*) AS count
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:170)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:140)
at android.content.ContentProviderProxy.query(ContentProviderNative.java:423)
at android.content.ContentResolver.query(ContentResolver.java:946)
at android.content.ContentResolver.query(ContentResolver.java:881)
at androidx.core.content.ContentResolverCompat.query(ContentResolverCompat.java:81)
at androidx.loader.content.CursorLoader.loadInBackground(CursorLoader.java:63)
at com.zhihu.matisse.internal.loader.AlbumLoader.loadInBackground(AlbumLoader.java:97)
at com.zhihu.matisse.internal.loader.AlbumLoader.loadInBackground(AlbumLoader.java:33)
at androidx.loader.content.AsyncTaskLoader.onLoadInBackground(AsyncTaskLoader.java:307)
at androidx.loader.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:60)
at androidx.loader.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:48)
at androidx.loader.content.ModernAsyncTask$2.call(ModernAsyncTask.java:141)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 
at java.lang.Thread.run(Thread.java:919) 

compileSdkVersion 29
defaultConfig { applicationId 'com.example.testmatisse' minSdkVersion 14 targetSdkVersion 29 versionCode 1 versionName "1.0" }

另外,我运行Demo时没有出问题,但是我已经基本保持和Demo一致的环境了,唯一不同就是依赖方式了。

抱歉,我修改到0.5.3-beta后此问题解决。请问为什么没有0.5.3正式版呢?是问题没有彻底解决吗?

@DanteAndroid
Copy link

有临时解决方案吗?项目用的是源码依赖的方式,没法直接升级……

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests