UnityNativeGallery icon indicating copy to clipboard operation
UnityNativeGallery copied to clipboard

Parameter "imagePath" is null or empty

Open KornyAS opened this issue 4 years ago • 19 comments

Hello, I have a problem with getting picture from gallery, it returns me "Parameter imagePath is null or empty" when I select any of the pictures. Permissions are granted. photo_2021-08-10_06-18-26

Reproduction steps Loaded from assetstore and use the plugin as ` NativeGallery.Permission permission = NativeGallery.GetImageFromGallery((path) => { print(path); Texture2D texture = NativeGallery.LoadImageAtPath(path); if (texture == null) { Debug.Log("Couldn't load texture from " + path); return; }

            BlitBlurShader.instance.EnableBlurFade(gameObject);
            contentMain.GetComponent<RawImage>().texture = texture;
            contentRender.GetComponent<RawImage>().texture = texture;
        }, "Select an image");
        print(permission);

`

  • Unity version: 2020.2.1f1
  • Platform: Android
  • Device: Redmi note 10 pro
  • How did you download the plugin: Asset Store

KornyAS avatar Aug 10 '21 03:08 KornyAS

Thank you for the detailed bug report. Can you reproduce this issue on any other device model (preferably not another Redmi)?

yasirkula avatar Aug 10 '21 07:08 yasirkula

Hello, I tested on a samsung galaxy S9+ and it works correctly. But whats's wrong with my redmi? How to fix it?

KornyAS avatar Aug 10 '21 10:08 KornyAS

I wonder that, as well 😞 Unfortunately, I have no idea why your device doesn't receive the image's path. Are there any useful logs in logcat?

yasirkula avatar Aug 10 '21 10:08 yasirkula

Here are my logs

2021-08-10 16:37:41.789 31240-31315/com.GoldenSoft.SeedsPlanner I/Unity: START GET IMAGE EditCustomPicture:SelectCustomPicture() UnityEngine.Events.UnityAction:Invoke() UnityEngine.Events.UnityEvent:Invoke() UnityEngine.EventSystems.EventFunction1:Invoke(T1, BaseEventData) UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction1) UnityEngine.EventSystems.StandaloneInputModule:ProcessTouchPress(PointerEventData, Boolean, Boolean) UnityEngine.EventSystems.StandaloneInputModule:ProcessTouchEvents() UnityEngine.EventSystems.StandaloneInputModule:Process() 2021-08-10 16:37:41.804 31240-31315/com.GoldenSoft.SeedsPlanner I/Unity: Granted EditCustomPicture:SelectCustomPicture() UnityEngine.Events.UnityAction:Invoke() UnityEngine.Events.UnityEvent:Invoke() UnityEngine.EventSystems.EventFunction1:Invoke(T1, BaseEventData) UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction1) UnityEngine.EventSystems.StandaloneInputModule:ProcessTouchPress(PointerEventData, Boolean, Boolean) UnityEngine.EventSystems.StandaloneInputModule:ProcessTouchEvents() UnityEngine.EventSystems.StandaloneInputModule:Process() 2021-08-10 16:37:41.842 31240-31315/com.GoldenSoft.SeedsPlanner D/ft.SeedsPlanne: PlayerBase::stop() from IPlayer 2021-08-10 16:37:41.842 31240-31315/com.GoldenSoft.SeedsPlanner D/AudioTrack: stop(sessionID=15425) 2021-08-10 16:37:41.842 31240-31315/com.GoldenSoft.SeedsPlanner D/AudioTrack: stop(2518): prior state:STATE_ACTIVE 2021-08-10 16:37:41.842 31240-31315/com.GoldenSoft.SeedsPlanner D/AudioTrack: stop(2518): called with 3956928 frames delivered 2021-08-10 16:37:52.049 31240-31417/com.GoldenSoft.SeedsPlanner I/SwappyDisplayManager: Terminating looper thread 2021-08-10 16:37:52.063 31240-32551/com.GoldenSoft.SeedsPlanner I/SwappyDisplayManager: Starting looper thread 2021-08-10 16:37:52.064 31240-31315/com.GoldenSoft.SeedsPlanner V/SwappyVk: SwappyVk initialized for VkDevice 0x705da5a420 using VK_GOOGLE_display_timing on Android 2021-08-10 16:37:52.064 31240-31315/com.GoldenSoft.SeedsPlanner I/SwappyVk: Returning refresh duration of 16666666 nsec (approx 60.000002 Hz) 2021-08-10 16:37:52.092 31240-31240/com.GoldenSoft.SeedsPlanner V/MediaRouter: Selecting route: RouteInfo{ name=Phone, description=null, status=null, category=RouteCategory{ name=System types=ROUTE_TYPE_LIVE_AUDIO ROUTE_TYPE_LIVE_VIDEO groupable=false }, supportedTypes=ROUTE_TYPE_LIVE_AUDIO ROUTE_TYPE_LIVE_VIDEO , presentationDisplay=null } 2021-08-10 16:37:52.104 31240-31407/com.GoldenSoft.SeedsPlanner I/AudioTrack: isLongTimeZoreData zoer date time 32 Seconds 2021-08-10 16:37:52.112 31240-31315/com.GoldenSoft.SeedsPlanner I/Unity: Null EditCustomPicture:<SelectCustomPicture>b__11_0(String) MediaPickCallback:Invoke(String) NativeGalleryNamespace.NGMediaReceiveCallbackAndroid:MediaReceiveCallback(String) System.Action:Invoke() 2021-08-10 16:37:52.113 31240-31315/com.GoldenSoft.SeedsPlanner E/Unity: ArgumentException: Parameter 'imagePath' is null or empty! at NativeGallery.LoadImageAtPath (System.String imagePath, System.Int32 maxSize, System.Boolean markTextureNonReadable, System.Boolean generateMipmaps, System.Boolean linearColorSpace) [0x00000] in <00000000000000000000000000000000>:0 at EditCustomPicture.<SelectCustomPicture>b__11_0 (System.String path) [0x00000] in <00000000000000000000000000000000>:0 at NativeGallery+MediaPickCallback.Invoke (System.String path) [0x00000] in <00000000000000000000000000000000>:0 at NativeGalleryNamespace.NGMediaReceiveCallbackAndroid.MediaReceiveCallback (System.String path) [0x00000] in <00000000000000000000000000000000>:0 at System.Action.Invoke () [0x00000] in <00000000000000000000000000000000>:0

KornyAS avatar Aug 10 '21 13:08 KornyAS

Here, it's the same but more comfortable view image

KornyAS avatar Aug 10 '21 13:08 KornyAS

Unfortunately, there aren't any suspicious logs here. At the following native line, either resultCode is not OK or returned data is null or empty: https://github.com/yasirkula/UnityNativeGallery/blob/29566b888db32bc10edfe0fb6307a1049560d801/.github/AAR%20Source%20(Android)/java/com/yasirkula/unity/NativeGalleryMediaPickerFragment.java#L309

I suspect your phone's gallery app has something to do with this. I'd recommend you to try 2 things:

  • Try using a different gallery app from Google Play (e.g. Google Photos)
  • Try calling this code before calling GetImageFromGallery:
using( AndroidJavaClass ajc = new AndroidJavaClass( "com.yasirkula.unity.NativeGalleryMediaPickerFragment" ) )
	ajc.SetStatic<bool>( "preferGetContent", true );

yasirkula avatar Aug 10 '21 16:08 yasirkula

No, this code didn't work, but it did't ask me to select a program, it just opened a file explorer. BTW I tried to use google photos etc but no result

KornyAS avatar Aug 10 '21 18:08 KornyAS

Let's hope we'll somehow find the cause of this issue in the near future. For now, I've no clue.

P.S. You can try NativeFilePicker.PickFile( (path)=>blabla, new string[] { "image/*" }); but I don't think it will work either.

yasirkula avatar Aug 10 '21 18:08 yasirkula

Yes, it doesn't work either(

KornyAS avatar Aug 11 '21 14:08 KornyAS

Can you replace NativeGallery.aar with the attached file (unzip it first to find the aar) and send me the logcat logs again?

NativeGallery.zip

yasirkula avatar Aug 11 '21 16:08 yasirkula

Here are logcat 2021-08-12 00:36:19.085 16051-16200/com.GoldenSoft.SeedsPlanner I/Unity: START GET IMAGE EditCustomPicture:SelectCustomPicture() UnityEngine.Events.UnityAction:Invoke() UnityEngine.Events.UnityEvent:Invoke() UnityEngine.EventSystems.EventFunction1:Invoke(T1, BaseEventData) UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction1) UnityEngine.EventSystems.StandaloneInputModule:ProcessTouchPress(PointerEventData, Boolean, Boolean) UnityEngine.EventSystems.StandaloneInputModule:ProcessTouchEvents() UnityEngine.EventSystems.StandaloneInputModule:Process() 2021-08-12 00:36:19.106 16051-16200/com.GoldenSoft.SeedsPlanner I/Unity: Granted EditCustomPicture:SelectCustomPicture() UnityEngine.Events.UnityAction:Invoke() UnityEngine.Events.UnityEvent:Invoke() UnityEngine.EventSystems.EventFunction1:Invoke(T1, BaseEventData) UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction1) UnityEngine.EventSystems.StandaloneInputModule:ProcessTouchPress(PointerEventData, Boolean, Boolean) UnityEngine.EventSystems.StandaloneInputModule:ProcessTouchEvents() UnityEngine.EventSystems.StandaloneInputModule:Process() 2021-08-12 00:36:19.148 16051-16200/com.GoldenSoft.SeedsPlanner D/ft.SeedsPlanne: PlayerBase::stop() from IPlayer 2021-08-12 00:36:19.148 16051-16200/com.GoldenSoft.SeedsPlanner D/AudioTrack: stop(sessionID=18049) 2021-08-12 00:36:19.148 16051-16200/com.GoldenSoft.SeedsPlanner D/AudioTrack: stop(2808): prior state:STATE_ACTIVE 2021-08-12 00:36:19.148 16051-16200/com.GoldenSoft.SeedsPlanner D/AudioTrack: stop(2808): called with 1601088 frames delivered 2021-08-12 00:36:25.945 16051-16051/com.GoldenSoft.SeedsPlanner D/Unity: === resultCode 0 2021-08-12 00:36:25.945 16051-16051/com.GoldenSoft.SeedsPlanner D/Unity: === data null 2021-08-12 00:36:26.060 16051-16391/com.GoldenSoft.SeedsPlanner I/SwappyDisplayManager: Terminating looper thread 2021-08-12 00:36:26.089 16051-16919/com.GoldenSoft.SeedsPlanner I/SwappyDisplayManager: Starting looper thread 2021-08-12 00:36:26.090 16051-16200/com.GoldenSoft.SeedsPlanner V/SwappyVk: SwappyVk initialized for VkDevice 0x7009e9caf0 using VK_GOOGLE_display_timing on Android 2021-08-12 00:36:26.090 16051-16200/com.GoldenSoft.SeedsPlanner I/SwappyVk: Returning refresh duration of 16666666 nsec (approx 60.000002 Hz) 2021-08-12 00:36:26.123 16051-16051/com.GoldenSoft.SeedsPlanner V/MediaRouter: Selecting route: RouteInfo{ name=Phone, description=null, status=null, category=RouteCategory{ name=System types=ROUTE_TYPE_LIVE_AUDIO ROUTE_TYPE_LIVE_VIDEO groupable=false }, supportedTypes=ROUTE_TYPE_LIVE_AUDIO ROUTE_TYPE_LIVE_VIDEO , presentationDisplay=null } 2021-08-12 00:36:26.145 16051-16200/com.GoldenSoft.SeedsPlanner I/Unity: Null EditCustomPicture:<SelectCustomPicture>b__11_0(String) MediaPickCallback:Invoke(String) NativeGalleryNamespace.NGMediaReceiveCallbackAndroid:MediaReceiveCallback(String) System.Action:Invoke() 2021-08-12 00:36:26.146 16051-16200/com.GoldenSoft.SeedsPlanner E/Unity: ArgumentException: Parameter 'imagePath' is null or empty! at NativeGallery.LoadImageAtPath (System.String imagePath, System.Int32 maxSize, System.Boolean markTextureNonReadable, System.Boolean generateMipmaps, System.Boolean linearColorSpace) [0x00000] in <00000000000000000000000000000000>:0 at EditCustomPicture.<SelectCustomPicture>b__11_0 (System.String path) [0x00000] in <00000000000000000000000000000000>:0 at NativeGallery+MediaPickCallback.Invoke (System.String path) [0x00000] in <00000000000000000000000000000000>:0 at NativeGalleryNamespace.NGMediaReceiveCallbackAndroid.MediaReceiveCallback (System.String path) [0x00000] in <00000000000000000000000000000000>:0 at System.Action.Invoke () [0x00000] in <00000000000000000000000000000000>:0 image

KornyAS avatar Aug 11 '21 21:08 KornyAS

Was it a fruitful information?

KornyAS avatar Aug 11 '21 21:08 KornyAS

I had a slight hope that another method of getting the data would work but it didn't. Thanks for testing. FYI, this function is called with resultCode=0 (CANCELED) and data=null. So there's absolutely no information provided to the plugin by the gallery: https://github.com/yasirkula/UnityNativeGallery/blob/29566b888db32bc10edfe0fb6307a1049560d801/.github/AAR%20Source%20(Android)/java/com/yasirkula/unity/NativeGalleryMediaPickerFragment.java#L301

yasirkula avatar Aug 12 '21 07:08 yasirkula

One last attempt: NativeGallery.zip

You don't have to attach logcat logs this time, I'm only interested if it works.

yasirkula avatar Aug 12 '21 07:08 yasirkula

No, it didn't work... Don't know even why, it think that I close gallery instead of selecting a photo....

KornyAS avatar Aug 12 '21 12:08 KornyAS

I'm using android.app.Fragment directly instead of Android Support Library's androidx.fragment.app.Fragment class. The latter might have some bugfixes and it is possible (though IMO a low chance) that this issue isn't present in androidx.fragment.app.Fragment.

I'm not using support library because installing support libraries in Unity makes the installation process 5x more complicated. I may come up with instructions to test the plugin with support library in the future to see if it resolves this issue but not at the moment. I'm not hopeful that it'll resolve the issue and I don't want to spend any time on learning support library stuff while I still have other things to do.

yasirkula avatar Aug 12 '21 13:08 yasirkula

Maybe if I create an empty project and install native gallery, I will be able to use it on my phone?....

KornyAS avatar Aug 13 '21 11:08 KornyAS

If you are talking about using support library, that requires modifying the native source code, as well.

yasirkula avatar Aug 13 '21 11:08 yasirkula

Hello, Im'm getting the same error on an Android 11 phone. On Android 9 it works well.

JaumeBoschAnglada avatar Nov 23 '22 10:11 JaumeBoschAnglada