-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Android - Newly created (empty) albums don't show up in getAlbums() #6
Comments
I just tried on an emulator (Pixel 3 API 29) to see if a newer android version would work, and the app crashed during the first getAlbums() call. Here is the stack trace: 2020-06-28 12:05:30.588 13491-13491/com.worldspinner.portraits I/Capacitor/Console: File: http://localhost/App.js - Line 161953 - Msg: �[34mdebug�[39m: Getting album
2020-06-28 12:05:30.588 13491-13585/com.worldspinner.portraits V/Capacitor/Plugin: To native (Capacitor plugin): callbackId: 19483038, pluginId: MediaPlugin, methodName: getAlbums
2020-06-28 12:05:30.588 13491-13585/com.worldspinner.portraits V/Capacitor: callback: 19483038, pluginId: MediaPlugin, methodName: getAlbums, methodData: {}
2020-06-28 12:05:30.588 13491-13567/com.worldspinner.portraits D/DEBUG LOG: GET ALBUMS
2020-06-28 12:05:30.589 13491-13567/com.worldspinner.portraits D/DEBUG LOG: HAS PERMISSION
2020-06-28 12:05:30.590 13491-13567/com.worldspinner.portraits D/DEBUG LOG: ___GET ALBUMS
2020-06-28 12:05:30.595 13491-13571/com.worldspinner.portraits D/eglCodecCommon: setVertexArrayObject: set vao to 1 (1) 17 6
2020-06-28 12:05:30.596 13491-13571/com.worldspinner.portraits D/eglCodecCommon: setVertexArrayObject: set vao to 3 (3) 32 0
2020-06-28 12:05:30.608 13491-13525/com.worldspinner.portraits D/eglCodecCommon: setVertexArrayObject: set vao to 1 (1) 7 4
2020-06-28 12:05:30.609 13491-13525/com.worldspinner.portraits D/eglCodecCommon: setVertexArrayObject: set vao to 0 (0) 7 8
2020-06-28 12:05:30.622 13491-13571/com.worldspinner.portraits D/eglCodecCommon: setVertexArrayObject: set vao to 1 (1) 17 6
2020-06-28 12:05:30.624 13491-13571/com.worldspinner.portraits D/eglCodecCommon: setVertexArrayObject: set vao to 3 (3) 32 0
2020-06-28 12:05:30.642 13491-13525/com.worldspinner.portraits D/eglCodecCommon: setVertexArrayObject: set vao to 1 (1) 7 4
2020-06-28 12:05:30.644 13491-13525/com.worldspinner.portraits D/eglCodecCommon: setVertexArrayObject: set vao to 0 (0) 7 8
2020-06-28 12:05:30.646 13491-13571/com.worldspinner.portraits D/eglCodecCommon: setVertexArrayObject: set vao to 1 (1) 17 6
2020-06-28 12:05:30.646 13491-13567/com.worldspinner.portraits E/Capacitor: Serious error executing plugin
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at com.getcapacitor.PluginHandle.invoke(PluginHandle.java:99)
at com.getcapacitor.Bridge$1.run(Bridge.java:515)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.os.HandlerThread.run(HandlerThread.java:67)
Caused by: java.lang.IllegalArgumentException: Invalid column DISTINCT bucket_display_name
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:170)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:140)
at android.content.ContentProviderProxy.query(ContentProviderNative.java:423)
at android.content.ContentResolver.query(ContentResolver.java:944)
at android.content.ContentResolver.query(ContentResolver.java:880)
at android.content.ContentResolver.query(ContentResolver.java:836)
at io.stewan.capacitor.media.MediaPlugin._getAlbums(MediaPlugin.java:62)
at io.stewan.capacitor.media.MediaPlugin.getAlbums(MediaPlugin.java:46)
at java.lang.reflect.Method.invoke(Native Method)
at com.getcapacitor.PluginHandle.invoke(PluginHandle.java:99)
at com.getcapacitor.Bridge$1.run(Bridge.java:515)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.os.HandlerThread.run(HandlerThread.java:67) |
Hi @stewwan, thanks for the reply! I just updated to the new version (and modified MainActivity.java appropriately). Unfortunately, I am still seeing the same behavior described above. |
Hello, Here is the album directory path printed by the plugin when I create the album myself : But when I don't create the album myself, here is the path printed before the error occurs : |
are you able to reproduce it using this example? |
@stewwan, That example is working on my physical device, but I am seeing the same stack trace when running on the emulator. I think the difference in behavior might be related to this check. I should have specified before, but the devices I am using are test devices that did not have any albums. If I create one manually, it is returned just like @amakh said. However, I cannot properly create albums with the plugin. |
Just to sum up, there are 2 different issues here:
|
@stewwan, is there any update on this? Or is there a suggested workaround? |
I'm also interested on an update regarding this. Thank's! |
Workaround for anyone trying to ignore This isn't the real issue, the problem is certainly coming from the fact that the creation path of the folder is different than the reading path's one but the little fix isn't affecting anything.
|
Hi @createdbyconnor |
I removed DISTINCT & it started working. But follow this to create my issue: Go to Gallery & Delete album created Album. As per this example: "My Album" Now, try to save the image, it will display the error that "Album is already exist" which is not. & it will not work. Now go to Gallery & make "My Album" manually & Save image code will start again but this time, it will also create another blank "My Album". So two "My Album" in gallery you will see. Is there any workaround for this? |
@stewones do you know when this issue might be sorted as this is a great plugin |
can someone try with latest plugin v3 and let me know? |
I am looking at this now with v3 and see the same issue - it looks like all the albums get returned by getAlbums (and I can see none are the one I'm about to try and create). Then when I call createAlbum I get "Album already exists" error. |
@stewones - i've encountered the same issue in v3 |
On iOS, this plugin work great. But on Android, there are plenty problems. For everyone who got stuck on this and are in rush, you can use capacitor-mediastore as a workaround for Android. I'v tested on almost all version of Android and it work just fine. Changing native code is also good but it's also have some bugs inside is cause your app to crash on some Android version, sadly atm I don't have enough time to dig in this plugin code. |
got a new androidy now I can debug this issue, looking into it right now. |
I'm having a hard time fixing this one. as a workaround you can just use the Capacitor Filesystem.writeFile({
recursive: true,
data: base64 as string,
path: `MY_ALBUM_NAME/my_image.png`,
directory: Directory.Documents,
}); The result expected would be stored on "Documents/MY_ALBUM_NAME/my_image.png". Tested on API 29+ |
@stewones or anyone else, is this still an issue? I'm unable to reproduce on my android device. You can try reproducing with the new example app; should be easy to use. |
@nkalupahana I upgraded to the latest version (capacitor 4 + this plugin) and |
@amakh Okay, I think I have an idea of what the problem is. When the plugin creates an "album", all that's doing is creating a folder in the filesystem. This won't show up in Let me know if this logic makes sense, or if there's something you know that might dispute this. (You can look for these folders yourself in your filesystem.) If so, some solutions; let me know what might make the most sense:
|
That is indeed what's happening because I remember trying to manually create an album (directly from the gallery app) and it wasn't in the same folder than the one created by the plugin. I agree that solution 1 looks better but tbh I don't have a big scope on android development. |
Alright, I'm on it. Will try to do solution 1, and we'll see how it goes. |
Solution one out in v5.0, testable with example app. |
Describe the bug
On android, the
media.getAlbums()
call returns an empty albums array. Thenmedia.createAlbum({ name })
returns the error message: "Album already exists"To Reproduce
Here is the code I am using (running on a physical android device). Perhaps I am using the API incorrectly? But I would expect this code to get an album and create it if it does not already exist.
Expected behavior
I would expect the code above to get the media album named "My Album" and create it if it does not already exist.
Desktop (please complete the following information):
Smartphone (please complete the following information):
Additional context
The same plugin and code is functioning properly on an iPhone.
The text was updated successfully, but these errors were encountered: