Amplify-android: While S3 upload file getting error as Error reading developer environment information on Android v10

Created on 27 Oct 2020  路  4Comments  路  Source: aws-amplify/amplify-android

I have an issue that I can't solve yet. While uploading files from Android to AWS Storage, I get an error:

E/MyAmplifyApp: Upload failed
AmplifyException {message=Issue uploading file., cause=java.lang.IllegalArgumentException: Invalid file: , recoverySuggestion=See included exception for more details and suggestions to fix.}

When I check the Amplify Developer Menu logs, I get this log:

Error reading developer environment information

This happens only on Android 10. It works on Android 7, 8 and 9.

my configuration in grade file has:

implementation 'com.amplifyframework:aws-storage-s3:1.4.2'
implementation 'com.amplifyframework:aws-auth-cognito:1.4.2'
Clarification Needed Closing Soon Usage Question

Most helpful comment

Hi @sencerturgut, given that this works on Android 7, 8, and 9, but fails on Android 10, I'm almost certain this is related to the Privacy Changes in Android 10. Essentially, apps are no longer allowed to access Files outside of the app-specific directory. You'll need to move your File to a directory that your app has permission to access, and then pass it to Amplify.Storage.upload(...).

As a side note, we are in the middle of adding an Amplify.Storage API that takes an InputStream (https://github.com/aws-amplify/amplify-android/pull/955), instead of a File, which are generally a little easier to work with in Android 10 and above. This change should be in our next release, so keep an eye out for that.

All 4 comments

Could you provide the code snippet that you're using to upload the file?

Hi @sencerturgut ,

Invalid file: error message is appended with the file path, but your message seems to end there. It means that the file that you are trying to upload has a blank path, which explains the invalid file error. Are you able to verify that the file you are trying to upload meets all of the following conditions:

  • is not null
  • is not a directory
  • exists
  • you have the read permission on the file

Hi @sencerturgut, given that this works on Android 7, 8, and 9, but fails on Android 10, I'm almost certain this is related to the Privacy Changes in Android 10. Essentially, apps are no longer allowed to access Files outside of the app-specific directory. You'll need to move your File to a directory that your app has permission to access, and then pass it to Amplify.Storage.upload(...).

As a side note, we are in the middle of adding an Amplify.Storage API that takes an InputStream (https://github.com/aws-amplify/amplify-android/pull/955), instead of a File, which are generally a little easier to work with in Android 10 and above. This change should be in our next release, so keep an eye out for that.

Update: We have released Amplify Android v1.6.1 recently, including the new uploadInputStream API. You can try it out using this version. I'll close this issue for now, but feel free to reopen it if you have further questions!

Was this page helpful?
0 / 5 - 0 ratings