apache / cordova-plugin-file-transfer

Apache Cordova File Transfer Plugin
https://cordova.apache.org/
Apache License 2.0
595 stars 888 forks source link

When to support android 10 or 11? #291

Closed qqakashi closed 2 years ago

qqakashi commented 3 years ago

Feature Request

Motivation Behind Feature

Feature Description

Currently, the identification path cannot be found on the Android 10 device, indicating error code 1 and permission error

Alternatives or Workarounds

sbellver commented 3 years ago

Any update? After upgrade to API 29 (mandatory in November 2020 at Google Developer) file transfer don't works in android (still working in iOS)

qqakashi commented 3 years ago

@sbellver yes ,after upgrade to cordova-android 9.0 file transfer don't works in android

KleggerKoder commented 3 years ago

I'm having no trouble using this plugin on AndroidX with cordova-android 9.0 we're using the cordova-plugin-androidx-adapter plugin perhaps that is what you are missing @sbellver @qqakashi

sbellver commented 3 years ago

Yes, is an issue about AndroidManifest permissions about filestorage

I set it manually and works, but i think using androidx-adapter will be more permanent

manelds commented 3 years ago

I have the same problem. In the documentation of new Android versión (https://developer.android.com/about/versions/11/privacy/storage) talk about of permission "ACTION_MANAGE_STORAGE".

I've add this permission to AndroidManifest.xml and it works fine:

<uses-permission android:name="android.permission.ACTION_MANAGE_STORAGE" />

Topiya commented 3 years ago

I am facing a same problem. Did anyone find any solution to this?

sbellver commented 3 years ago

Add https://www.npmjs.com/package/cordova-plugin-androidx-adapter plugin to your ionic app

yogeshshsf commented 3 years ago

I am facing same problem. i am in ionic 1 project using cordova 5.4.1. can you give solution for this? @sbellver i tried to install androidx-adapter plugin but it is not getting in my project. MicrosoftTeams-image

sbellver commented 3 years ago

You can (must) upgrade to cordova 8. I'm on Cordova 9.0 and still with ionic 1

jfoclpf commented 3 years ago

I've add this permission to AndroidManifest.xml and it works fine:

<uses-permission android:name="android.permission.ACTION_MANAGE_STORAGE" />

Anyone else tried this solution? Does it work for android 11?

sebafra commented 3 years ago

I've add this permission to AndroidManifest.xml and it works fine: <uses-permission android:name="android.permission.ACTION_MANAGE_STORAGE" />

Anyone else tried this solution? Does it work for android 11?

Did you find a solution?

jfoclpf commented 3 years ago

@sebafra apparently that solution works only for Android 10. For Android 11 a working solution is to use a social sharing plugin that allows the user to save the file whenever he wants, but it works only for saving a file outside of App's sandbox, not for reading. Check also this thread: https://github.com/apache/cordova-plugin-file/issues/426

sebafra commented 3 years ago

@sebafra apparently that solution works only for Android 10. For Android 11 a working solution is to use a social sharing plugin that allows the user to save the file whenever he wants, but it works only for saving a file outside of App's sandbox, not for reading. Check also this thread: apache/cordova-plugin-file#426

I need to read files from gallery, social sharing plugin allow to do this?

jfoclpf commented 3 years ago

I need to read files from gallery, social sharing plugin allow to do this?

No, it is just a workaround to save files, not to read!

richrichDev commented 2 years ago

for anyone struggling with this , use this solution : modify FileTransfer.java as follow :

remove : import org.apache.cordova.Whitelist; add : import org.apache.cordova.AllowList;`

remove:

Boolean shouldAllowRequest = null;
        if (isLocalTransfer) {
            shouldAllowRequest = true;
        }
        if (shouldAllowRequest == null) {
            try {
                Method gwl = webView.getClass().getMethod("getWhitelist");
                Whitelist whitelist = (Whitelist)gwl.invoke(webView);
                shouldAllowRequest = Whitelist.isUrlWhiteListed(source);
            } catch (NoSuchMethodException e) {
            } catch (IllegalAccessException e) {
            } catch (InvocationTargetException e) {
            }
        }

add :

Boolean shouldAllowRequest = null;
          if (isLocalTransfer) {
              shouldAllowRequest = true;
          }
          if (shouldAllowRequest == null) {
              try {
                  Method gwl = webView.getClass().getMethod("getWhitelist");
                  AllowList whitelist = (AllowList)gwl.invoke(webView);
                  shouldAllowRequest = whitelist.isUrlAllowListed(source);
              } catch (NoSuchMethodException e) {
              } catch (IllegalAccessException e) {
              } catch (InvocationTargetException e) {
              }
          }