Lamelynx / GodotGetImagePlugin-Android

Godot plugin to select image from gallery or camera on Android device.
MIT License
71 stars 4 forks source link

Does not work with 4.2beta #16

Closed leoyanis closed 8 months ago

leoyanis commented 9 months ago

I tried making the .aar file like the description said but it gives an error when doing that. Did some debugging with chatgpt and it builds the .aar file but the plugin doesnt work anymore.

This is from the terminal ./gradlew assembleRelease

Starting a Gradle Daemon (subsequent builds will be faster) <======-------> 46% EXECUTING [4s]

Transforming godot-lib.release.aar (project :godot-lib.release) with AarToC<======-------> Task :godotgetimage:compileReleaseKotlin FAILED e: file:///Users/yanis/Desktop/GODOT/GodotGetImagePlugin-Android-master%202/GodotGetImagePlugin/godotgetimage/src/main/java/com/gmail/lamelynx/godotgetimage/GodotGetImage.kt:234:29 Cannot access 'context': it is private in 'Godot' e: file:///Users/yanis/Desktop/GODOT/GodotGetImagePlugin-Android-master%202/GodotGetImagePlugin/godotgetimage/src/main/java/com/gmail/lamelynx/godotgetimage/GodotGetImage.kt:397:36 Cannot access 'context': it is private in 'Godot' e: file:///Users/yanis/Desktop/GODOT/GodotGetImagePlugin-Android-master%202/GodotGetImagePlugin/godotgetimage/src/main/java/com/gmail/lamelynx/godotgetimage/GodotGetImage.kt:407:54 Cannot access 'context': it is private in 'Godot' e: file:///Users/yanis/Desktop/GODOT/GodotGetImagePlugin-Android-master%202/GodotGetImagePlugin/godotgetimage/src/main/java/com/gmail/lamelynx/godotgetimage/GodotGetImage.kt:467:19 Cannot access 'context': it is private in 'Godot' e: file:///Users/yanis/Desktop/GODOT/GodotGetImagePlugin-Android-master%202/GodotGetImagePlugin/godotgetimage/src/main/java/com/gmail/lamelynx/godotgetimage/GodotGetImage.kt:512:39 Cannot access 'context': it is private in 'Godot' e: file:///Users/yanis/Desktop/GODOT/GodotGetImagePlugin-Android-master%202/GodotGetImagePlugin/godotgetimage/src/main/java/com/gmail/lamelynx/godotgetimage/GodotGetImage.kt:553:45 Cannot access 'context': it is private in 'Godot' e: file:///Users/yanis/Desktop/GODOT/GodotGetImagePlugin-Android-master%202/GodotGetImagePlugin/godotgetimage/src/main/java/com/gmail/lamelynx/godotgetimage/GodotGetImage.kt:562:27 Cannot access 'context': it is private in 'Godot'

FAILURE: Build failed with an exception.

BUILD FAILED in 11s 18 actionable tasks: 18 executed

Could you help please? :)

Ayomideabdulazeez commented 9 months ago

Yes I'm also getting this error

granitrocky commented 9 months ago

I haven't tested this plugin yet, but I was able to get it to compile by swapping out the godot.context objects in the code to activity?.applicationContext?

leoyanis commented 9 months ago

I managed to make it work. I did a custom compile for godot 4.2 + and i changed the context stuff to something else chatgpt told me. Ask chatgpt and it will work haha

djordjije commented 8 months ago

I managed to make it work. I did a custom compile for godot 4.2 + and i changed the context stuff to something else chatgpt told me. Ask chatgpt and it will work haha

Would you be able to provide a zip file of the code or .aar / gdap that worked for you? I am trying to implement this as well, but I am still very new to the plugins.

leoyanis commented 8 months ago

I managed to make it work. I did a custom compile for godot 4.2 + and i changed the context stuff to something else chatgpt told me. Ask chatgpt and it will work haha

Would you be able to provide a zip file of the code or .aar / gdap that worked for you? I am trying to implement this as well, but I am still very new to the plugins.

Yeah sure here you go. plugin.zip

djordjije commented 8 months ago

Thank you! I will give this a shot and hopefully can build on top of that.

djordjije commented 8 months ago

I managed to make it work. I did a custom compile for godot 4.2 + and i changed the context stuff to something else chatgpt told me. Ask chatgpt and it will work haha

Would you be able to provide a zip file of the code or .aar / gdap that worked for you? I am trying to implement this as well, but I am still very new to the plugins.

Yeah sure here you go. plugin.zip

I can confirm that this worked on my end. I was able to use it with the example project in the repo. You did a fantastic job. Is there a way to contact you further regarding this? I wanted to learn how to do these adjustments like for this plugin. And I don't know where to start.

I could actually learn a lot by looking at the changes that you made to the original code. If you would be able to provide a zip of the code changes, that would be amazing.

leoyanis commented 8 months ago

I managed to make it work. I did a custom compile for godot 4.2 + and i changed the context stuff to something else chatgpt told me. Ask chatgpt and it will work haha

Would you be able to provide a zip file of the code or .aar / gdap that worked for you? I am trying to implement this as well, but I am still very new to the plugins.

Yeah sure here you go. plugin.zip

I can confirm that this worked on my end. I was able to use it with the example project in the repo. You did a fantastic job. Is there a way to contact you further regarding this? I wanted to learn how to do these adjustments like for this plugin. And I don't know where to start.

I could actually learn a lot by looking at the changes that you made to the original code. If you would be able to provide a zip of the code changes, that would be amazing.

Hey man im sorry but chatgpt did all the work for me. I dont know much about kotlin and yeah. Unfortunately i accidentally deleted the working code and i didnt bother trying to debug the original again so yeah.

Lamelynx commented 8 months ago

You probably need to change the object godot.context to getActivity() .

Try tro replace all occurences of context with getActivity() (or create a class property private Activity activity and add line this.activity = getActivity() in the init { function. Then use this.activity instead of godot.context? )

Lamelynx commented 8 months ago

This is now resolved. Updated the plugin to Godot plugin version 2 architecture and from now on the plugin supports only Godot 4.2+.