Closed devalanrs closed 3 years ago
Did you request the Read files permission on runtime?
I am able to replicate this on Android 11.
Glad to see there are so many users 😄
Since Android 10, they have changed the storage access rules and we can't get the file path using my current implementation.
For android 10: you can add this attribute to your application element in your AndroidManifest.xml (just a quick fix until I fix the plugin)
<application ...
android:requestLegacyExternalStorage="true"
...>
For android 11 and beyond: Seems like I'll have update the plugin code. I'll try to make a fix soon
This is blocked by the underlying android nearby connections SDK. See this issue: https://github.com/android/connectivity-samples/issues/176
Glad to see there are so many users 😄
Since Android 10, they have changed the storage access rules and we can't get the file path using my current implementation.
For android 10: you can add this attribute to your application element in your AndroidManifest.xml (just a quick fix until I fix the plugin)
<application ... android:requestLegacyExternalStorage="true" ...>
For android 11 and beyond: Seems like I'll have update the plugin code. I'll try to make a fix soon
this works but the file is received in a hidden folder named '.nearby' in the downloads directory. How do i change the directory of received files because it is not accessible.
@GauravGunjal43
this works but the file is received in a hidden folder named '.nearby' in the downloads directory. How do I change the directory of received files because it is not accessible?
Ah, yes they have been rolling this out for a few weeks(The files are now being saved to the .nearby
folder).
Are you sure you not able to rename the file to another directory on Android 10? Can you provide any error logs for this?
Note that it may not be possible for us to be able to do anything until they resolve the issue with the underlying SDK as it does not expose the file URI of the payload.
any updates on this?
We can't do anything until they fix this in the underlying android nearby connections library.
Hi everyone, I have released a new version with a fix for this - https://pub.dev/packages/nearby_connections/versions/3.1.0
Payload.uri
is now exposed and is usable on all android versions.DOWNLOADS/.nearby/
which is a hidden folder and the file cannot be renamed in-place on Android 11 and beyond. So you must move and rename this file.copyFileAndDeleteOriginal
has been added to work with uri
since they cannot be used directly.Payload.filepath
has been deprecated and is only available on Android 10 and below.
Error Logs
D/nearby_connections(17721): ad.onConnectionResult D/nearby_connections(17721): onPayloadReceived D/nearby_connections(17721): onPayloadTransferUpdate I/flutter (17721): Tt3c: -4780165049267211412:IMG_20210409_181224.jpg I/flutter (17721): NoSuchMethodError: The method 'exists' was called on null. I/flutter (17721): Receiver: null I/flutter (17721): Tried calling: exists() I/flutter (17721): InProgress D/nearby_connections(17721): onPayloadTransferUpdate I/flutter (17721): Success W/NearbyConnections(17721): Failed to create Payload from ParcelablePayload: Java file not found at /storage/emulated/0/Download/.nearby/-4780165049267211412 W/NearbyConnections(17721): java.io.FileNotFoundException: open failed: EACCES (Permission denied) W/NearbyConnections(17721): at android.os.ParcelFileDescriptor.openInternal(ParcelFileDescriptor.java:344) W/NearbyConnections(17721): at android.os.ParcelFileDescriptor.open(ParcelFileDescriptor.java:231) W/NearbyConnections(17721): at com.google.android.gms.nearby.connection.Payload$File.zza(Unknown Source:12) W/NearbyConnections(17721): at com.google.android.gms.internal.nearby.zzfl.zza(Unknown Source:81) W/NearbyConnections(17721): at com.google.android.gms.internal.nearby.zzav.zza(Unknown Source:5) W/NearbyConnections(17721): at com.google.android.gms.internal.nearby.zzdx.dispatchTransaction(Unknown Source:28) W/NearbyConnections(17721): at com.google.android.gms.internal.nearby.zzb.onTransact(Unknown Source:22) W/NearbyConnections(17721): at android.os.Binder.execTransactInternal(Binder.java:1159) W/NearbyConnections(17721): at android.os.Binder.execTransact(Binder.java:1123) D/nearby_connections(17721): onPayloadReceived D/AndroidRuntime(17721): Shutting down VM E/AndroidRuntime(17721): FATAL EXCEPTION: main