[TIMOB-26248] Hyperloop: Android - Cannot use android.provider.MediaStore.Images.Media API
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2020-05-01T20:36:41.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Hyperloop |
Labels | engReviewed, hyperloop |
Reporter | Donald Anderson |
Assignee | Joshua Quick |
Created | 2018-07-31T11:14:06.000+0000 |
Updated | 2020-05-01T20:36:41.000+0000 |
Description
If I create a new project and add
var mediastore = require('android.provider.MediaStore.Images.Media');
I get the following error.
Requested module not found: android.provider.MediaStore.Images.Media
Trace level logs are attached
Attachments
File | Date | Size |
---|---|---|
Android MediaStore.Images.Media logs | 2018-07-31T11:13:35.000+0000 | 362871 |
What if you only require
android.provider.MediaStore
and accessImages.Media
from the result? e.g.Looking [here](https://stackoverflow.com/questions/23343783/how-can-i-fix-errors-about-imports-in-this-code), someone tried your import natively and it did not work either, so you may need to import it like above. It may be because of it's static context, but thats just troubleshooting. In other examples like [here](https://stackoverflow.com/questions/13772138/android-read-any-specific-image-from-sd-card-and-display-it-as-bitmap), it's always
MediaStore
being required, it's sub-constants are accessed via it then.I can't seem to get at the media sub-class. if I use this.
it prints the following
If I use this
It prints this.
It doesn't seem to matter if I try to import the class directly or access it though it's parents, it doesn't seem to exist.
Then it might indeed be a bug. [~jquick] [~gmathews] do you know more?
This appears to be a Hyperloop limitation. The
Media
class withinandroid.provider.MediaStore$Images$Media
is an inner class within anotherImages
inner class. Hyperloop can access the 1st inner class, but not an inner class within another inner class. I can successfully require it in Hyperloop using the dollar sign'$'
version above, but Hyperloop will fail to provide the static constants/methods. So, it doesn't solve anything. You can work-around this issue for now by using Google'sContentResolver
class instead, which is what theMedia
class uses internally. Have a look at Google's code here... [MediaStore.java#L861](https://github.com/aosp-mirror/platform_frameworks_base/blob/master/core/java/android/provider/MediaStore.java#L861) And theirContentResolver
class documentation can be found here... https://developer.android.com/reference/android/content/ContentResolverThis was resolved as of Titanium 9.0.0 via ticket [TIMOB-27298].