compose-webview-multiplatform icon indicating copy to clipboard operation
compose-webview-multiplatform copied to clipboard

Kotlin 2.0.0 Support

Open Deorigami opened this issue 1 year ago • 15 comments

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'.

Deorigami avatar May 05 '24 07:05 Deorigami

@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.

KevinnZou avatar May 09 '24 00:05 KevinnZou

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'.

msasikanth avatar May 12 '24 00:05 msasikanth

@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.

KevinnZou avatar May 12 '24 08:05 KevinnZou

@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?

msasikanth avatar May 13 '24 05:05 msasikanth

@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

KevinnZou avatar May 13 '24 07:05 KevinnZou

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 avatar May 13 '24 07:05 msasikanth

This is what I have

Screenshot 2024-05-13 at 12 52 59 Screenshot 2024-05-13 at 12 53 10

msasikanth avatar May 13 '24 07:05 msasikanth

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")

msasikanth avatar May 13 '24 07:05 msasikanth

@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 avatar May 14 '24 11:05 Deorigami

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

Deorigami avatar May 14 '24 11:05 Deorigami

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

KevinnZou avatar May 15 '24 00:05 KevinnZou

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

Deorigami avatar May 17 '24 03:05 Deorigami