KevinnZou / compose-webview-multiplatform

WebView for JetBrains Compose Multiplatform
https://kevinnzou.github.io/compose-webview-multiplatform/
Apache License 2.0
318 stars 40 forks source link

Kotlin 2.0.0 Support #148

Open Deorigami opened 4 weeks ago

Deorigami commented 4 weeks ago

Currently im using Kotlin 2.0.0-RC2, i take a look onto you samples using new resources plugin and i cant create assets folder inside composeResources to store my html file the compilation error says:

> Task :app_core:generateResourceAccessorsForCommonMain FAILED e: generateResourceAccessorsForCommonMain task was failed: java.lang.IllegalStateException: Unknown resource type: 'assets'.

KevinnZou commented 3 weeks ago

@Deorigami Thanks for your feedback! It seems that Kotlin 2.0 does not allow the custom resource folder. However, to make HTML files packaged to each platform correctly, we must create that 'assets' folder under composeResoruces. I will contact JetBrains for a solution.

msasikanth commented 3 weeks ago

Even on Compose v1.6.2 this seems to be the case? I am getting the same error when I placed assets folder inside composeResources to store my HTML file.

GenerateResClassTask was failed:
java.lang.IllegalStateException: Unknown resource type: 'assets'.
KevinnZou commented 2 weeks ago

@msasikanth @Deorigami I apologize for the inconvenience caused by this issue. I have submitted this issue to JetBrains for an official solution. One temporary solution could be to create a resources folder like we did before version 1.6.0 and place the assets folder under it. Please let me know if you encounter any further issues.

msasikanth commented 2 weeks ago

@msasikanth @Deorigami I apologize for the inconvenience caused by this issue. I have submitted this issue to JetBrains for an official solution. One temporary solution could be to create a resources folder like we did before version 1.6.0 and place the assets folder under it. Please let me know if you encounter any further issues.

I tried to place it in resources/assets, but it didn't get packaged to the final APK. So, this seems to be an issue even with 1.6.2 Compose as well?

KevinnZou commented 2 weeks ago

@msasikanth Did you place the resources/assets under commonMain? It works fine on my side? Which platforms are you running on?

截屏2024-05-13 15 13 16
msasikanth commented 2 weeks ago

I did. Maybe I missed on something on Gradle configuration to tell Android SDK about this folder as the resources as well.

When I compiled, I could see the assets folder, but it only contained the Compose resources font directory.

I compiled it on MacOS BTW

msasikanth commented 2 weeks ago

This is what I have

Screenshot 2024-05-13 at 12 52 59 Screenshot 2024-05-13 at 12 53 10
msasikanth commented 2 weeks ago

It's just missing the Gradle sourceset configuration. Once I add this, it's working now. Sorry about that

sourceSets["main"].resources.srcDirs("src/commonMain/resources")
Deorigami commented 2 weeks ago

@KevinnZou hey there, after i put the assets into commonMain/resources/assets .. throwing this error now

Entry assets/new_map.html is a duplicate but no duplicate handling strategy has been set. Please refer to https://docs.gradle.org/8.4/dsl/org.gradle.api.tasks.Copy.html#org.gradle.api.tasks.Copy:duplicatesStrategy for details.
Deorigami commented 2 weeks ago

this error occurs when i put sourceSets["main"].resources.srcDirs("src/commonMain/resources") .. if i remove this. it compiled .. but the xml is not shown

(ComposeWebView) WebView Loading Failed with error: The requested URL was not found on this server. (ComposeWebView) didFailNavigation

KevinnZou commented 2 weeks ago

@Deorigami Did you also place new_map.html in other place? It seems that you have duplicate files.

Deorigami commented 2 weeks ago

no i dont .. for now i cannot load any Html file .. but im able to load the file from composeResource and make it a string, so i have to dump all of my Html + Js code inside 1 file.

WIll be nice if we can separate the file like it used to