Open kuldipopenxcell opened 3 months ago
In my case, always stuck in these code only in Android
const uri = await viewRef.current.capture();
there's no error, just still going on. But iOS is working fine.
I tried with this code also but there is no error logs and no clue to fix this.
const captureSnapshot = async () => {
try {
const uri = await captureRef(viewRef, {
format: 'png', // You can change the format if needed
quality: 1, // Quality of the image, from 0 to 1
});
// Do something with the captured image URI (e.g., save it to disk or display it)
console.log('Snapshot URI:', uri);
} catch (error) {
console.error('Error capturing snapshot:', error);
}
};
Hi guys, any advance with this issue? I have the same problem with react-native 0.73.6, on ios works great, but with Android, nothing happens
Thanks!!
Hi guys, I have found the alternative for this. since this is not working well for Android. Here you can use React Native Skia: Snapshot Views | React Native
Hi guys. The same problem here. But I came up with a workaround. Just capture the full screen. After that you can clip the full screen image to the shape whatever you want.
import { captureScreen } from "react-native-view-shot";
captureScreen({
format: "jpg",
quality: 0.8,
}).then(
(uri) => console.log("Image saved to", uri),
(error) => console.error("Oops, snapshot failed", error)
);
Hi guys. The same problem here. But I came up with a workaround. Just capture the full screen. After that you can clip the full screen image to the shape whatever you want.
import { captureScreen } from "react-native-view-shot"; captureScreen({ format: "jpg", quality: 0.8, }).then( (uri) => console.log("Image saved to", uri), (error) => console.error("Oops, snapshot failed", error) );
Tried this and still not working for me, still no file saved/blank when shared.
Hi guys, I ran into the same issue as OP and found a workaround by switching from core API RN Share to react-native-share.
Keep using the ViewShot
config but replace your capture function with this :
const onCapture = async () => {
const uri = await captureRef(ref, {
format: 'png',
quality: 0.9,
});
await Share.open({url: uri});
};
For whatever reason, the core Share API seems to expose url
param only for iOS, that is what should cause the issue on Android.
Resolve this in Android using React Native Patch Packages.
@YogeshwarSharma Still not working.
Hope, You have used patch-package and applied react-native-view-shot+3.8.0.patch
Yes, i did. But mapview still missing. I try set collapsable to false/true but same result.
This is my captureOptions
const options ={ format: 'png', quality: 1, result: 'tmpfile', snapshotContentContainer: false, handleGLSurfaceViewOnAndroid: true, useRenderInContext: false,}
When i set handleGLSurfaceViewOnAndroid
to true
Mapview will appear but other view will not and handleGLSurfaceViewOnAndroid
to false
. Mapview will disappear.
bug report
In react native latest version (0.73.6) snapshot is not capturing in Android device. It works fine in IOS.
Version & Platform
Platform: Android
Expected behavior
It should return with URI of the image
Actual behavior
It returns nothing
Sample Code