Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Android absolute path issue #118

Closed
N7ghtm4r3 opened this issue Sep 24, 2024 · 13 comments · Fixed by #120
Closed

Android absolute path issue #118

N7ghtm4r3 opened this issue Sep 24, 2024 · 13 comments · Fixed by #120

Comments

@N7ghtm4r3
Copy link

Hi, I'm using the library on a KMP project, and when I try to get the absolute path of a picture (when it has been selected with the picker)
the Android's application crashes with the following exception:

java.io.FileNotFoundException: /picker/0/com.android.providers.media.photopicker/media/1000000042: open failed: ENOENT (No such file or directory) at libcore.io.IoBridge.open(IoBridge.java:574) at java.io.FileInputStream.<init>(FileInputStream.java:160) at kotlin.io.FilesKt__FileReadWriteKt.readBytes(FileReadWrite.kt:69)

This is similar to this issue, I missed out something in the configuration?

@ghost
Copy link

ghost commented Sep 25, 2024

Created a PR to address this issue #120.

@N7ghtm4r3 Could you take a look at the change and maybe test it on your device and the image that was causing the issue to see if it works properly now?

@N7ghtm4r3
Copy link
Author

Hi, I saw the changes and I think should be the correct implementation because seems like the getFilePath method I found that currently works. If is not a problem can I test it tomorrow?

@ghost
Copy link

ghost commented Sep 26, 2024

No rush. Let me know when you get to try it, just want to make sure the fix is correct.

@N7ghtm4r3
Copy link
Author

Yes sure!

@N7ghtm4r3
Copy link
Author

N7ghtm4r3 commented Sep 26, 2024

Sorry for the delay, I have tested it now, but unfortanly this is the result:

Process: com.tecknobit.nova, PID: 4737 java.io.FileNotFoundException: 1000000042.jpg: open failed: ENOENT (No such file or directory) at libcore.io.IoBridge.open(IoBridge.java:574) at java.io.FileInputStream.<init>(FileInputStream.java:160) at kotlin.io.FilesKt__FileReadWriteKt.readBytes(FileReadWrite.kt:69) at com.tecknobit.equinox.environment.helpers.EquinoxRequester.changeProfilePic(EquinoxRequester.kt:141) at com.tecknobit.nova.ui.screens.profile.ProfileScreenViewModel.changeProfilePic$lambda$0(ProfileScreenViewModel.kt:56) at com.tecknobit.nova.ui.screens.profile.ProfileScreenViewModel.$r8$lambda$eBfBYVe1QE6psMVpXadslXm3BUg(Unknown Source:0) at com.tecknobit.nova.ui.screens.profile.ProfileScreenViewModel$$ExternalSyntheticLambda4.invoke(Unknown Source:2) at com.tecknobit.equinox.Requester.sendRequest(Requester.kt:513) at com.tecknobit.equinox.Requester.sendRequest$default(Requester.kt:507) at com.tecknobit.nova.ui.screens.profile.ProfileScreenViewModel.changeProfilePic(ProfileScreenViewModel.kt:54) at com.tecknobit.nova.ui.screens.profile.ProfileScreen.ArrangeScreenContent$lambda$2$lambda$1(ProfileScreen.kt:74) at com.tecknobit.nova.ui.screens.profile.ProfileScreen.$r8$lambda$Yerxr4iDEQoTW09MyDNRt1HHlqY(Unknown Source:0) at com.tecknobit.nova.ui.screens.profile.ProfileScreen$$ExternalSyntheticLambda1.invoke(Unknown Source:6) at io.github.vinceglb.filekit.compose.FileKitComposeKt$rememberFilePickerLauncher$returnedLauncher$1$1$1.invokeSuspend(FileKitCompose.kt:52) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:102) at androidx.compose.ui.platform.AndroidUiDispatcher.performTrampolineDispatch(AndroidUiDispatcher.android.kt:81) at androidx.compose.ui.platform.AndroidUiDispatcher.access$performTrampolineDispatch(AndroidUiDispatcher.android.kt:41) at androidx.compose.ui.platform.AndroidUiDispatcher$dispatchCallback$1.run(AndroidUiDispatcher.android.kt:57) at android.os.Handler.handleCallback(Handler.java:958) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:205) at android.os.Looper.loop(Looper.java:294) at android.app.ActivityThread.main(ActivityThread.java:8177) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971) Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [androidx.compose.ui.platform.MotionDurationScaleImpl@3b7d2d4, androidx.compose.runtime.BroadcastFrameClock@b798c7d, StandaloneCoroutine{Cancelling}@13d1772, AndroidUiDispatcher@853e7c3] Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory) at libcore.io.Linux.open(Native Method) at libcore.io.ForwardingOs.open(ForwardingOs.java:563) at libcore.io.BlockGuardOs.open(BlockGuardOs.java:274) at libcore.io.ForwardingOs.open(ForwardingOs.java:563) at android.app.ActivityThread$AndroidOs.open(ActivityThread.java:8063) at libcore.io.IoBridge.open(IoBridge.java:560) ... 26 more
The path is different otherwise:

from: /picker/0/com.android.providers.media.photopicker/media/1000000042
to: 1000000042.jpg

@N7ghtm4r3
Copy link
Author

The getFilePath method (the workaround) actually return this instead: /data/user/0/com.tecknobit.nova/files/1000000042.jpg,
can be used that method to solve the issue?

@ghost
Copy link

ghost commented Sep 26, 2024

@N7ghtm4r3 Can you test out the new commit? It should do the same as your workaround, but without reading the whole file

@N7ghtm4r3
Copy link
Author

Yes sure!

@N7ghtm4r3
Copy link
Author

N7ghtm4r3 commented Sep 26, 2024

Really great job! It works now

Thank you!

@ghost
Copy link

ghost commented Sep 26, 2024

Good to know, a bit weird that we have to actually create the file and check its path from there when the file can be opened with the name, but idk, Android stuff

@ghost ghost linked a pull request Sep 26, 2024 that will close this issue
@N7ghtm4r3
Copy link
Author

Yes I think the same, really weird

@Hussienfahmy
Copy link

Hussienfahmy commented Sep 29, 2024

Hi, when will the fix be released?

@vinceglb
Copy link
Owner

Hi! I'm going to create a new release today with the fix 👌

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants