cordova-plugin-document-scanner
cordova-plugin-document-scanner copied to clipboard
Ionic Capacitor - Android 10 - FileNotFoundException
Describe the bug
I am trying to use this plugin with ionic capacitor and on Android 10 it never shows the image crop screen, caused by the following exception:
2020-08-03 13:26:05.320 27707-27707/si.test.app D/ViewRootImpl@9f2e8cd[ScanActivity]: Relayout returned: old=(0,0,1080,2280) new=(0,0,1080,2280) req=(1080,2280)4 dur=8 res=0x1 s={false 0} ch=false 2020-08-03 13:26:05.321 27707-27707/si.test.app D/ViewRootImpl@9f2e8cd[ScanActivity]: stopped(false) old=true 2020-08-03 13:26:05.328 27707-27707/si.test.app W/System.err: java.io.FileNotFoundException: open failed: ENOENT (No such file or directory) 2020-08-03 13:26:05.329 27707-27707/si.test.app W/System.err: at android.os.ParcelFileDescriptor.openInternal(ParcelFileDescriptor.java:315) 2020-08-03 13:26:05.329 27707-27707/si.test.app W/System.err: at android.os.ParcelFileDescriptor.open(ParcelFileDescriptor.java:220) 2020-08-03 13:26:05.329 27707-27707/si.test.app W/System.err: at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1505) 2020-08-03 13:26:05.329 27707-27707/si.test.app W/System.err: at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1427) 2020-08-03 13:26:05.329 27707-27707/si.test.app W/System.err: at com.scanlibrary.PickImageFragment.getBitmap(PickImageFragment.java:388) 2020-08-03 13:26:05.329 27707-27707/si.test.app W/System.err: at com.scanlibrary.PickImageFragment.onActivityResult(PickImageFragment.java:315) 2020-08-03 13:26:05.329 27707-27707/si.test.app W/System.err: at android.app.Activity.dispatchActivityResult(Activity.java:8321) 2020-08-03 13:26:05.329 27707-27707/si.test.app W/System.err: at android.app.ActivityThread.deliverResults(ActivityThread.java:5230) 2020-08-03 13:26:05.329 27707-27707/si.test.app W/System.err: at android.app.ActivityThread.handleSendResult(ActivityThread.java:5278) 2020-08-03 13:26:05.329 27707-27707/si.test.app W/System.err: at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:51) 2020-08-03 13:26:05.329 27707-27707/si.test.app W/System.err: at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) 2020-08-03 13:26:05.329 27707-27707/si.test.app W/System.err: at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) 2020-08-03 13:26:05.329 27707-27707/si.test.app W/System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2220) 2020-08-03 13:26:05.329 27707-27707/si.test.app W/System.err: at android.os.Handler.dispatchMessage(Handler.java:107) 2020-08-03 13:26:05.329 27707-27707/si.test.app W/System.err: at android.os.Looper.loop(Looper.java:237) 2020-08-03 13:26:05.329 27707-27707/si.test.app W/System.err: at android.app.ActivityThread.main(ActivityThread.java:8016) 2020-08-03 13:26:05.329 27707-27707/si.test.app W/System.err: at java.lang.reflect.Method.invoke(Native Method) 2020-08-03 13:26:05.329 27707-27707/si.test.app W/System.err: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) 2020-08-03 13:26:05.329 27707-27707/si.test.app W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1076) 2020-08-03 13:26:05.330 27707-27707/si.test.app D/ViewRootImpl@9f2e8cd[ScanActivity]: stopped(false) old=false 2020-08-03 13:26:05.339 27707-27707/si.test.app D/ViewRootImpl@9f2e8cd[ScanActivity]: Relayout returned: old=(0,0,1080,2280) new=(0,0,1080,2280) req=(1080,2280)0 dur=8 res=0x7 s={true 502479515648} ch=true 2020-08-03 13:26:05.339 27707-27948/si.test.app D/OpenGLRenderer: createReliableSurface : 0x75f8c71ac0(0x74fe1cf000) 2020-08-03 13:26:05.339 27707-27948/si.test.app I/mali_winsys: new_window_surface() [1080x2280] return: 0x3000 2020-08-03 13:26:05.342 27707-27948/si.test.app D/OpenGLRenderer: makeCurrent EglSurface : 0x0 -> 0x756a168200 2020-08-03 13:26:05.345 27707-27707/si.test.app D/ViewRootImpl@9f2e8cd[ScanActivity]: MSG_WINDOW_FOCUS_CHANGED 1 1 2020-08-03 13:26:05.346 27707-27707/si.test.app D/InputMethodManager: prepareNavigationBarInfo() DecorView@d4f4b1e[ScanActivity] 2020-08-03 13:26:05.346 27707-27707/si.test.app D/InputMethodManager: getNavigationBarColor() -855310 2020-08-03 13:26:05.347 27707-27707/si.test.app D/InputMethodManager: prepareNavigationBarInfo() DecorView@d4f4b1e[ScanActivity] 2020-08-03 13:26:05.347 27707-27707/si.test.app D/InputMethodManager: getNavigationBarColor() -855310 2020-08-03 13:26:05.347 27707-27707/si.test.app V/InputMethodManager: Starting input: tba=si.test.app ic=null mNaviBarColor -855310 mIsGetNaviBarColorSuccess true , NavVisible : true , NavTrans : false 2020-08-03 13:26:05.347 27707-27707/si.test.app D/InputMethodManager: startInputInner - Id : 0 2020-08-03 13:26:05.347 27707-27707/si.test.app I/InputMethodManager: startInputInner - mService.startInputOrWindowGainedFocus
To Reproduce
Steps to reproduce the behavior:
- Create an app with Ionic Cli
- Add capacitor android platform
- Install plugin
- Try to scan a document
Expected behavior Document content returned to the app.
Smartphone (please complete the following information):
- Device: Samsung Galaxy S10e
- OS: Android 10
- @capacitor/core : 2.3.0
- @capacitor/android: 2.3.0
- cordova-plugin-document-scanner: 4.2.5
This could also be related:
2020-08-03 13:42:50.749 1278-1278/? E/Util: writeImageDataToRequestedUri : failed to make directory or the directory already existed. 2020-08-03 13:42:50.760 1278-1278/? E/Util: writeImageDataToRequestedUri : Returned because outputStream IOException.
Me too. Android 10 it never shows the image crop screen.
I solved the problem with the solution provided on this issue : https://github.com/apache/cordova-plugin-file/issues/408
By adding android:requestLegacyExternalStorage="true"
to the application tag directly in the AndroidManifest.xml file generated by Cordova. It's seems to be a problem with API 29...
Hey sorry I have been inactive for a while. I tested this with an Android 10 phone but I could not replicate it. I double checked if it was compiling with api level 29 as well. Could this be a device specific issue? or an ionic specific issue ? I tested with vanilla cordova.
Do let me know if you guys have any info, work on this plugin is going to become a huge focus now so I will be dedicating a considerable amount of time to fixing any issues that are cropping up.
Released a new beta version of the plugin.
To test it :-
- Make sure to remove the old version using
cordova plugin rm cordova-plugin-document-scanner
- To test it add the following to your project
-
cordova plugin add [email protected]
-
cordova plugin add cordova plugin add cordova-plugin-androidx
-
cordova plugin add cordova-plugin-androidx-adapter
-
If you guys could help by testing this beta version and let me know if it solved your issue, I can release the 5.0.0 version. Latest plugin also solves this issue
Hi @ChrisTomAlx ,
Thanks for the update, I will give a try without adding android:requestLegacyExternalStorage="true"
property to the manifest.
And it's weird that you don't had the issue on your device, I was personally running the application on a Honor 10 view. My ionic info ouput if it helps :
Ionic:
Ionic CLI : 5.4.16 (/usr/local/lib/node_modules/ionic)
Ionic Framework : ionic-angular 3.9.2
@ionic/app-scripts : 3.1.10
Cordova:
Cordova CLI : 8.1.2 ([email protected])
Cordova Platforms : android 9.0.0
Cordova Plugins : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 1.2.1, (and 10 other plugins)
Utility:
cordova-res : 0.15.1
native-run : 1.0.0
System:
Android SDK Tools : 26.1.1 (/home/ajrdev/Android/Sdk)
NodeJS : v10.0.0 (/usr/local/bin/node)
npm : 5.6.0
OS : Linux 5.4
I'll keep you posted, have a nice day as well :)
Thanks @AJRdev
I am using cordova cli 10.0.0
with cordova-android 9.0.0
. But as per android docs you are on the right tracks. Its really strange that I am unable to reproduce it.
Also the android:requestLegacyExternalStorage="true"
solution will stop working on API 30, so I would like to implement a permanent fix for this issue.
Hello,
Does it possible to add requestLegacyExternalStorage into config.xml cordova file? Can you post here an example ?
Thank you
I've just rebuild the project with the requestLegacyExternalStorage attribute but still doesn't works. I use SDK r29. A separate native camera window is opened when I try to scan as I report in #86 issue.
With cordova cli 10 it looks that doesn't exists "cordova-plugin-androidx" plugin.
@scramatte if you are using version 5.0.0-beta.0 of the plugin, please refer to this comment
@ChrisTomAlx I've done what you explained in the comment but still have the issue. since cordova-android@9 , cordova-plugin-androidx" have been deprecated.
@scramatte even after adding android:requestLegacyExternalStorage="true"
?