TeamAmaze / AmazeFileManager

Material design file manager for Android
https://teamamaze.xyz
GNU General Public License v3.0
5.37k stars 1.58k forks source link

IllegalStateException on createDocument when ext. SDCARD changed #1005

Open ildar opened 6 years ago

ildar commented 6 years ago

I once opened different SD CARD. After getting back my usual SD Amaze crashes on a folder rename operation. adb.logcat.log

EmmanuelMess commented 6 years ago

Extract:

02-08 14:45:01.929  4274  4274 D ExternalStorage: After updating volumes, found 2 active roots
02-08 14:45:01.943  2504  3129 W bt_btif : ### UNDERFLOW :: ONLY READ 0 BYTES OUT OF 512 ###
02-08 14:45:01.943  2504  3129 W bt_btif : btif_media_aa_prep_sbc_2_send underflow 5, 0
02-08 14:45:01.982  4274  4287 W DocumentsProvider: Failed during query
02-08 14:45:01.982  4274  4287 W DocumentsProvider: java.io.FileNotFoundException: No root for E0CD-812E
02-08 14:45:01.982  4274  4287 W DocumentsProvider:     at com.android.externalstorage.ExternalStorageProvider.getFileForDocId(ExternalStorageProvider.java:252)
02-08 14:45:01.982  4274  4287 W DocumentsProvider:     at com.android.externalstorage.ExternalStorageProvider.getFileForDocId(ExternalStorageProvider.java:239)
02-08 14:45:01.982  4274  4287 W DocumentsProvider:     at com.android.externalstorage.ExternalStorageProvider.queryChildDocuments(ExternalStorageProvider.java:431)
02-08 14:45:01.982  4274  4287 W DocumentsProvider:     at android.provider.DocumentsProvider.query(DocumentsProvider.java:498)
02-08 14:45:01.982  4274  4287 W DocumentsProvider:     at android.content.ContentProvider.query(ContentProvider.java:1017)
02-08 14:45:01.982  4274  4287 W DocumentsProvider:     at android.content.ContentProvider$Transport.query(ContentProvider.java:238)
02-08 14:45:01.982  4274  4287 W DocumentsProvider:     at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:112)
02-08 14:45:01.982  4274  4287 W DocumentsProvider:     at android.os.Binder.execTransact(Binder.java:453)
02-08 14:45:02.018   605   799 E Sensors : Lightsensor values:174.000000
02-08 14:45:02.021  4069  4099 W DocumentFile: Failed query: java.lang.NullPointerException: Attempt to invoke interface method 'boolean android.database.Cursor.moveToNext()' on a null object reference
02-08 14:45:02.026  4274  4286 E DatabaseUtils: Writing exception to parcel
02-08 14:45:02.026  4274  4286 E DatabaseUtils: java.lang.IllegalStateException: Failed call android:createDocument
02-08 14:45:02.026  4274  4286 E DatabaseUtils:     at android.provider.DocumentsProvider.call(DocumentsProvider.java:691)
02-08 14:45:02.026  4274  4286 E DatabaseUtils:     at android.content.ContentProvider$Transport.call(ContentProvider.java:398)
02-08 14:45:02.026  4274  4286 E DatabaseUtils:     at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:283)
02-08 14:45:02.026  4274  4286 E DatabaseUtils:     at android.os.Binder.execTransact(Binder.java:453)
02-08 14:45:02.026  4274  4286 E DatabaseUtils: Caused by: java.io.FileNotFoundException: No root for E0CD-812E
02-08 14:45:02.026  4274  4286 E DatabaseUtils:     at com.android.externalstorage.ExternalStorageProvider.getFileForDocId(ExternalStorageProvider.java:252)
02-08 14:45:02.026  4274  4286 E DatabaseUtils:     at com.android.externalstorage.ExternalStorageProvider.getFileForDocId(ExternalStorageProvider.java:239)
02-08 14:45:02.026  4274  4286 E DatabaseUtils:     at com.android.externalstorage.ExternalStorageProvider.createDocument(ExternalStorageProvider.java:344)
02-08 14:45:02.026  4274  4286 E DatabaseUtils:     at android.provider.DocumentsProvider.call(DocumentsProvider.java:647)
02-08 14:45:02.026  4274  4286 E DatabaseUtils:     ... 3 more
02-08 14:45:02.052  4069  4099 W Documents: Failed to create document
02-08 14:45:02.052  4069  4099 W Documents: java.lang.IllegalStateException: Failed call android:createDocument
02-08 14:45:02.052  4069  4099 W Documents:     at android.os.Parcel.readException(Parcel.java:1628)
02-08 14:45:02.052  4069  4099 W Documents:     at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:183)
02-08 14:45:02.052  4069  4099 W Documents:     at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:135)
02-08 14:45:02.052  4069  4099 W Documents:     at android.content.ContentProviderProxy.call(ContentProviderNative.java:646)
02-08 14:45:02.052  4069  4099 W Documents:     at android.content.ContentProviderClient.call(ContentProviderClient.java:437)
02-08 14:45:02.052  4069  4099 W Documents:     at android.provider.DocumentsContract.createDocument(DocumentsContract.java:949)
02-08 14:45:02.052  4069  4099 W Documents:     at android.provider.DocumentsContract.createDocument(DocumentsContract.java:932)
02-08 14:45:02.052  4069  4099 W Documents:     at android.support.v4.provider.DocumentsContractApi21.createFile(DocumentsContractApi21.java:37)
02-08 14:45:02.052  4069  4099 W Documents:     at android.support.v4.provider.DocumentsContractApi21.createDirectory(DocumentsContractApi21.java:42)
02-08 14:45:02.052  4069  4099 W Documents:     at android.support.v4.provider.TreeDocumentFile.createDirectory(TreeDocumentFile.java:40)
02-08 14:45:02.052  4069  4099 W Documents:     at com.amaze.filemanager.filesystem.FileUtil.getDocumentFile(FileUtil.java:843)
02-08 14:45:02.052  4069  4099 W Documents:     at com.amaze.filemanager.filesystem.FileUtil.isWritableNormalOrSaf(FileUtil.java:701)
02-08 14:45:02.052  4069  4099 W Documents:     at com.amaze.filemanager.filesystem.Operations.checkFolder(Operations.java:474)
02-08 14:45:02.052  4069  4099 W Documents:     at com.amaze.filemanager.filesystem.Operations.access$000(Operations.java:31)
02-08 14:45:02.052  4069  4099 W Documents:     at com.amaze.filemanager.filesystem.Operations$3.doInBackground(Operations.java:418)
02-08 14:45:02.052  4069  4099 W Documents:     at com.amaze.filemanager.filesystem.Operations$3.doInBackground(Operations.java:328)
02-08 14:45:02.052  4069  4099 W Documents:     at android.os.AsyncTask$2.call(AsyncTask.java:295)
02-08 14:45:02.052  4069  4099 W Documents:     at java.util.concurrent.FutureTask.run(FutureTask.java:237)
02-08 14:45:02.052  4069  4099 W Documents:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
02-08 14:45:02.052  4069  4099 W Documents:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
02-08 14:45:02.052  4069  4099 W Documents:     at java.lang.Thread.run(Thread.java:818)
02-08 14:45:02.058  4069  4099 E AndroidRuntime: FATAL EXCEPTION: AsyncTask #5
02-08 14:45:02.058  4069  4099 E AndroidRuntime: Process: com.amaze.filemanager, PID: 4069
02-08 14:45:02.058  4069  4099 E AndroidRuntime: Theme: themes:{default=overlay:org.cyanogenmod.hexolibre, iconPack:org.xphnx.ameixa, fontPkg:org.cyanogenmod.hexolibre, com.android.systemui=overlay:org.cyanogenmod.hexolibre, com.android.systemui.navbar=overlay:org.cyanogenmod.hexolibre}
02-08 14:45:02.058  4069  4099 E AndroidRuntime: java.lang.RuntimeException: An error occurred while executing doInBackground()
02-08 14:45:02.058  4069  4099 E AndroidRuntime:    at android.os.AsyncTask$3.done(AsyncTask.java:309)
02-08 14:45:02.058  4069  4099 E AndroidRuntime:    at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
02-08 14:45:02.058  4069  4099 E AndroidRuntime:    at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
02-08 14:45:02.058  4069  4099 E AndroidRuntime:    at java.util.concurrent.FutureTask.run(FutureTask.java:242)
02-08 14:45:02.058  4069  4099 E AndroidRuntime:    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
02-08 14:45:02.058  4069  4099 E AndroidRuntime:    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
02-08 14:45:02.058  4069  4099 E AndroidRuntime:    at java.lang.Thread.run(Thread.java:818)
02-08 14:45:02.058  4069  4099 E AndroidRuntime: Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.support.v4.provider.DocumentFile android.support.v4.provider.DocumentFile.findFile(java.lang.String)' on a null object reference
02-08 14:45:02.058  4069  4099 E AndroidRuntime:    at com.amaze.filemanager.filesystem.FileUtil.getDocumentFile(FileUtil.java:839)
02-08 14:45:02.058  4069  4099 E AndroidRuntime:    at com.amaze.filemanager.filesystem.FileUtil.isWritableNormalOrSaf(FileUtil.java:701)
02-08 14:45:02.058  4069  4099 E AndroidRuntime:    at com.amaze.filemanager.filesystem.Operations.checkFolder(Operations.java:474)
02-08 14:45:02.058  4069  4099 E AndroidRuntime:    at com.amaze.filemanager.filesystem.Operations.access$000(Operations.java:31)
02-08 14:45:02.058  4069  4099 E AndroidRuntime:    at com.amaze.filemanager.filesystem.Operations$3.doInBackground(Operations.java:418)
02-08 14:45:02.058  4069  4099 E AndroidRuntime:    at com.amaze.filemanager.filesystem.Operations$3.doInBackground(Operations.java:328)
02-08 14:45:02.058  4069  4099 E AndroidRuntime:    at android.os.AsyncTask$2.call(AsyncTask.java:295)
02-08 14:45:02.058  4069  4099 E AndroidRuntime:    at java.util.concurrent.FutureTask.run(FutureTask.java:237)
02-08 14:45:02.058  4069  4099 E AndroidRuntime:    ... 3 more
02-08 14:45:02.092   605   622 W ActivityManager:   Force finishing activity com.amaze.filemanager/.activities.MainActivity
salim-b commented 6 years ago

I got the same issue, i.e. Amaze crashes after every attempt to write to the SD card since it has been reformatted. I was looking for a way to trigger the SAF "workaround" to grant Amaze access again to the new SD card, but as it appears one can't just manually open this dialog from the UI:

SAF dialog

Edit: the logcat entries of the crash:

02-10 01:24:02.592   956  3722 I ActivityManager: Start proc 6313:com.amaze.filemanager/u0a76 for activity com.amaze.filemanager/.activities.MainActivity
02-10 01:24:23.284   956  1740 I ActivityManager: Start proc 6393:com.android.externalstorage/u0a12 for content provider com.android.externalstorage/.ExternalStorageProvider
--------- beginning of crash
02-10 01:24:23.418  6313  6336 E AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
02-10 01:24:23.418  6313  6336 E AndroidRuntime: Process: com.amaze.filemanager, PID: 6313
02-10 01:24:23.418  6313  6336 E AndroidRuntime: java.lang.RuntimeException: An error occurred while executing doInBackground()
02-10 01:24:23.418  6313  6336 E AndroidRuntime:    at android.os.AsyncTask$3.done(AsyncTask.java:325)
02-10 01:24:23.418  6313  6336 E AndroidRuntime:    at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
02-10 01:24:23.418  6313  6336 E AndroidRuntime:    at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
02-10 01:24:23.418  6313  6336 E AndroidRuntime:    at java.util.concurrent.FutureTask.run(FutureTask.java:242)
02-10 01:24:23.418  6313  6336 E AndroidRuntime:    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
02-10 01:24:23.418  6313  6336 E AndroidRuntime:    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
02-10 01:24:23.418  6313  6336 E AndroidRuntime:    at java.lang.Thread.run(Thread.java:761)
02-10 01:24:23.418  6313  6336 E AndroidRuntime: Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.support.v4.provider.DocumentFile android.support.v4.provider.DocumentFile.findFile(java.lang.String)' on a null object reference
02-10 01:24:23.418  6313  6336 E AndroidRuntime:    at com.amaze.filemanager.filesystem.FileUtil.getDocumentFile(FileUtil.java:839)
02-10 01:24:23.418  6313  6336 E AndroidRuntime:    at com.amaze.filemanager.filesystem.FileUtil.isWritableNormalOrSaf(FileUtil.java:701)
02-10 01:24:23.418  6313  6336 E AndroidRuntime:    at com.amaze.filemanager.filesystem.Operations.checkFolder(Operations.java:474)
02-10 01:24:23.418  6313  6336 E AndroidRuntime:    at com.amaze.filemanager.filesystem.Operations.access$000(Operations.java:31)
02-10 01:24:23.418  6313  6336 E AndroidRuntime:    at com.amaze.filemanager.filesystem.Operations$1.doInBackground(Operations.java:168)
02-10 01:24:23.418  6313  6336 E AndroidRuntime:    at com.amaze.filemanager.filesystem.Operations$1.doInBackground(Operations.java:91)
02-10 01:24:23.418  6313  6336 E AndroidRuntime:    at android.os.AsyncTask$2.call(AsyncTask.java:305)
02-10 01:24:23.418  6313  6336 E AndroidRuntime:    at java.util.concurrent.FutureTask.run(FutureTask.java:237)
02-10 01:24:23.418  6313  6336 E AndroidRuntime:    ... 3 more
02-10 01:24:23.422   956  1741 W ActivityManager:   Force finishing activity com.amaze.filemanager/.activities.MainActivity
aidaho commented 5 years ago

new SD card

I had the same problem: Amaze crashes doing any write operation to a new card.
You can re-trigger access dialog by doing write operation in sd card root.

"Write Access Required" dialog will be triggered again and after granting write access it's business as usual.

salim-b commented 5 years ago

You can re-trigger access dialog by doing write operation in sd card root.

That worked indeed (created a new file in the SD card root)! Thank you for the hint!

EmmanuelMess commented 3 years ago

Related #2142 (I think).