[TIMOB-24256] Android: openPhotoGallery is not working at all on SDK 6.0.0.GA,6.0.1.GA
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2017-01-23T14:09:07.000+0000 |
Affected Version/s | Release 6.0.0 |
Fix Version/s | Release 6.0.2 |
Components | Android |
Labels | n/a |
Reporter | David Fox |
Assignee | Gary Mathews |
Created | 2016-12-15T07:26:02.000+0000 |
Updated | 2017-05-05T12:23:07.000+0000 |
Description
I can't get openPhotoGallery to work on Android since upgrading to 6.0.0.
The gallery opens fine, but when an image is selected, and I try to read the blob, I'm getting the following error:
[WARN] : W/System.err: java.lang.NullPointerException: Attempt to invoke virtual method 'char[] java.lang.String.toCharArray()' on a null object reference
[WARN] : W/System.err: at java.io.File.fixSlashes(File.java:183)
[WARN] : W/System.err: at java.io.File.<init>(File.java:130)
[WARN] : W/System.err: at org.appcelerator.titanium.io.TitaniumBlob.getFile(TitaniumBlob.java:77)
[WARN] : W/System.err: at org.appcelerator.titanium.TiBlob.getLength(TiBlob.java:364)
[WARN] : W/System.err: at org.appcelerator.kroll.runtime.v8.V8Function.nativeInvoke(Native Method)
[WARN] : W/System.err: at org.appcelerator.kroll.runtime.v8.V8Function.callSync(V8Function.java:57)
[WARN] : W/System.err: at org.appcelerator.kroll.runtime.v8.V8Function.call(V8Function.java:43)
[WARN] : W/System.err: at org.appcelerator.kroll.runtime.v8.V8Function$1.run(V8Function.java:70)
[WARN] : W/System.err: at android.os.Handler.handleCallback(Handler.java:739)
[WARN] : W/System.err: at android.os.Handler.dispatchMessage(Handler.java:95)
[WARN] : W/System.err: at android.os.Looper.loop(Looper.java:148)
[WARN] : W/System.err: at org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run(KrollRuntime.java:118)
[WARN] : EGL_emulation: eglSurfaceAttrib not implemented
[WARN] : OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xdc79b4e0, error=EGL_SUCCESS
[ERROR] : TiExceptionHandler: (main) [20134,28149] ----- Titanium Javascript Runtime Error -----
[ERROR] : TiExceptionHandler: (main) [0,28149] - In undefined:230,23
[ERROR] : TiExceptionHandler: (main) [0,28149] - Message: Uncaught Attempt to invoke virtual method 'char[] java.lang.String.toCharArray()' on a null object reference
[ERROR] : TiExceptionHandler: (main) [1,28150] - Source: if (me.attachedImage.length > 5242880) {
[WARN] : EGL_emulation: eglSurfaceAttrib not implemented
[WARN] : OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xe8e3e9a0, error=EGL_SUCCESS
Hello, Please send the sample code for us to test.
I'm using:
I did some more tests with this. I created a brand new project and tested Ti.Media.openPhotoGallery. While I don't get the error, it just doesn't seem to work at all. None of the callbacks get called when the image is selected. Are you able to get any calls to Ti.Media.openPhotoGallery on Android 6 with SDK 6.0 to work at all? I haven't been able to.
Hi, I have tested the issue. The galary opens fine as expected. See my code
You have to call openPhotoGallery in an event listener. Thanks.
Hello, I am testing in Android 6.0.1. Try using my code structure and modify it to your need. Now, The JIRA link you provide the issue is different than your issue and that's already fixed. Hello, We will test your issue when we have the full reproducible sample code. Thanks.
Dear Sharif, Can you please modify the 'success' section to below: and see if you can manage to read any property of 'e.media'. success : function(e) { imageView.image = e.media; console.log(e.media); // or console.log(JSON.Stringify(e.media)); }, Thanks
Yeah, I just tested, and while Sharif's example works, it does not work when you try to do anything with e.media aside from just sticking it in an ImageView. Like Rohit points out, that example will fail because of the console.log erroring out trying to work with e.media. You also can't do anything like e.media.length which is very important functionality.
master: https://github.com/appcelerator/titanium_mobile/pull/8716
Verified fix, using the test case provided by [~gmathews] in https://github.com/appcelerator/titanium_mobile/pull/8716. Was able to open the gallery and insert a picture in to the application without any error provided permissions were set as stated in the test case.
*Environment*
Reopening to add version and to allow back port.
Would this fix be included in the latest 6.1.0 build from http://builds.appcelerator.com? If so, at least in the Android emulator, the bug is still occurring for me. I'm testing in Genymotion Samsung Galaxy S7 running Android 6.0.0. The same crash occurs. Everything seems fine when the Titanium SDK is switched to 5.x.
PR (6_0_X): https://github.com/appcelerator/titanium_mobile/pull/8774 [~dfoxinator] Can you give us some more infos, an example project and the logs you get (even when they are the same)? Thx!
Verified fix for
6.0.2
backport, using the test case provided by Gary Mathews in https://github.com/appcelerator/titanium_mobile/pull/8716. Was able to open the gallery and insert a picture in to the application without any error provided permissions were set as stated in the test case. *Environment*Hey, I did some more testing. On an Android device running Android 6.0, the fix seems to work. However, on the Genymotion Samsung Galaxy S7 Android 6.0.0 device, the same error occurs after selecting an image: [ERROR] : TiExceptionHandler: (main) [0,14815] - Message: Uncaught Attempt to invoke virtual method 'char[] java.lang.String.toCharArray()' on a null object reference However, on the Google Nexus 6P Android 7.0.0 emulator, selecting an image works. Have you tested this in an emulator running Android 6? Thanks.
Hey [~dfoxinator] I tested the application on two 6.0.0 devices (Genymotion Samsung Galaxy S7 and Genymotion Samsung Galaxy S6) and i was able to open the photo gallery and select an image without any errors as long as permissions were set. Could you provide some more information? Thanks. *Environment*
*Note* Used
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
in the xml file *Code used to tested with*Closing the issue as fixed.
Hi guys I'm having this problem, only when I select an image from the gallery in the download category. External read permissions are enabled. *Environment: Nexus 5X 7.1.1*
*Console*
I am able to reproduce this error when selecting an image from
downloads
only. *Environment*Is there an update on this? This issue is definitely not fixed and shouldn't be closed.