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

Ionic Capacitor - Android 10 - FileNotFoundException #82

Open
gregor-srdic opened this issue Aug 3, 2020 · 14 comments
Open

Ionic Capacitor - Android 10 - FileNotFoundException #82

gregor-srdic opened this issue Aug 3, 2020 · 14 comments

Comments

@gregor-srdic
Copy link

gregor-srdic commented Aug 3, 2020

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:

  1. Create an app with Ionic Cli
  2. Add capacitor android platform
  3. Install plugin
  4. 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
@gregor-srdic
Copy link
Author

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.

@niruttomtom
Copy link

Me too. Android 10 it never shows the image crop screen.

@AJRdev
Copy link

AJRdev commented Sep 12, 2020

I solved the problem with the solution provided on this issue : apache/cordova-plugin-file#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...

@ChrisTomAlx
Copy link
Collaborator

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.

Cheers and have a nice day :)
Chris
Neutrinos

@ChrisTomAlx
Copy link
Collaborator

Released a new beta version of the plugin.

To test it :-

  1. Make sure to remove the old version using cordova plugin rm cordova-plugin-document-scanner
  2. To test it add the following to your project
    • cordova plugin add cordova-plugin-document-scanner@5.0.0-beta.0
    • 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

Cheers and have a nice day :)
Chris
Neutrinos

@AJRdev
Copy link

AJRdev commented Nov 10, 2020

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 (cordova-lib@8.1.1)
   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 :)

@ChrisTomAlx
Copy link
Collaborator

ChrisTomAlx commented Nov 11, 2020

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.

Cheers,
Chris
Neutrinos

@scramatte
Copy link

scramatte commented Nov 16, 2020

Hello,

Does it possible to add requestLegacyExternalStorage into config.xml cordova file?
Can you post here an example ?

Thank you

@scramatte
Copy link

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.

@scramatte
Copy link

With cordova cli 10 it looks that doesn't exists "cordova-plugin-androidx" plugin.

@ChrisTomAlx
Copy link
Collaborator

ChrisTomAlx commented Nov 16, 2020

@scramatte if you are using version 5.0.0-beta.0 of the plugin, please refer to this comment

Cheers and have a nice day :)
Chris
Neutrinos

@scramatte
Copy link

@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.

@ChrisTomAlx
Copy link
Collaborator

ChrisTomAlx commented Nov 17, 2020

@scramatte even after adding android:requestLegacyExternalStorage="true" ?

Cheers and have a nice day :)
Chris
Neutrinos

@ChrisTomAlx
Copy link
Collaborator

@scramatte you might be interested in this discussion

Cheers and have a nice day :)
Chris
Neutrinos

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

No branches or pull requests

5 participants