0 Replies Latest reply on Jun 8, 2018 2:54 PM by joshual77436912

    Can't get File Selector to work on Android - Is it Possible?

    joshual77436912 Level 1

      Hello, I hope all is well!

       

      I am losing hope that it is possible to use a file upload on Android with phonegap (PhoneGap Build). Yet I have seen it done and have to believe this is possible with PhoneGap which gives me enough hope to post this question. This seems like such a common need that it has to be supported for Android.

       

      I have had a working solution that works perfectly on iOS but I cannot get the file selector to work on Android.



      Essentially my application needs to simply allow the user to choose a photo from there device or alternatively take a picture and have that they selected through the file selector. When the user selects the file it uploads to the web.

       

      I am using PL upload And the upload happens to Amazon S3. (all this works perfectly on ios)

       

      I actually built a sample app that does nothing but load of webview using InAppBrowser and I load the demo page of PL upload here https://www.plupload.com/examples

       

      I have also created a super simple stripped down version to block troubleshoot the file selector by including this link as my URL for my inAppBrowser: https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_fileupload_get



      I can click the “add files” button on ios build with no issues at all. I can select my file and it uploads right away.

       

      With Android I click upload files and it does nothing. The exact point of failure is when the user clicks a UI element to invoke the file selector UI for Android. When clicking the UI to upload a file the button does not appear to do anything at all.



      I have run this on ios without any issues at all.

       

      These are the relevant pieces from my config.xml

       

          <preference name="phonegap-version" value="cli-7.0.1" />

          <preference name="android-build-tool" value="gradle" />

          <preference name="android-targetSdkVersion" value="26"/>

          <preference name="android-minSdkVersion" value="17" />

          <plugin name="cordova-android-support-gradle-release">

              <variable name="ANDROID_SUPPORT_VERSION" value="26.0.0"/>

          </plugin>



         <plugin name="cordova-plugin-battery-status" source="npm" spec="~1.1.1" />

         <plugin name="cordova-plugin-camera" source="npm" spec="~2.1.1" />

         <plugin name="cordova-plugin-media-capture" source="npm" spec="~1.2.0" />

         <plugin name="cordova-plugin-console" source="npm" spec="~1.0.2" />

         <plugin name="cordova-plugin-contacts" source="npm" spec="~2.0.1" />

         <plugin name="cordova-plugin-device" source="npm" spec="~1.1.1" />

         <plugin name="cordova-plugin-device-motion" source="npm" spec="~1.2.0" />

         <plugin name="cordova-plugin-device-orientation" source="npm" spec="~1.0.2" />

         <plugin name="cordova-plugin-dialogs" source="npm" spec="~1.2.0" />

         <plugin name="cordova-plugin-file" source="npm" spec="~4.1.1" />

         <plugin name="cordova-plugin-file-transfer" source="npm" spec="~1.5.0" />

         <plugin name="cordova-plugin-geolocation" source="npm" spec="~2.1.0" />

         <plugin name="cordova-plugin-globalization" source="npm" spec="~1.0.3" />

         <plugin name="cordova-plugin-inappbrowser" source="npm" spec="~1.3.0" />

         <plugin name="cordova-plugin-media" source="npm" spec="~2.2.0" />

         <plugin name="cordova-plugin-network-information" source="npm" spec="~1.2.0" />

         <plugin name="cordova-plugin-splashscreen" source="npm" spec="~3.2.1" />

         <plugin name="cordova-plugin-statusbar" source="npm" spec="~2.1.2" />

         <plugin name="cordova-plugin-vibration" source="npm" spec="~2.1.0" />

         <plugin name="cordova-plugin-whitelist" source="npm" spec="~1.2.1" />



      I have also tried setting fileChunking = false in filetransfer.js which was another common recommendation I saw. That did not make a difference on Android and the file selector would not trigger.

       

      I have been doing tests with BrowserStack App Life also and have gone through device logs to try to pinpoint what might be going wrong.

       

      In the end I just need to be able to have the file selector appear on Android and choose a file. I have everything else taken care of from there.

       

      In its simplest state, I need to be able to do something like this https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_fileupload_get

       

      Thanks for your help!

       

      Josh