Hi team, in my sample compose multiplatform app fo...
# compose-web
s
Hi team, in my sample compose multiplatform app for android, ios and desktop, i added web support following the official compose web sample imageviewer , but i am not able to run web app, I am not able to resolve some dependencies, like unresolved reference : CanvasBasedWindow and while i am trying to run the app using ./gradlew webAppwasmRun, Then i am Getting following issues in logs:
Copy code
FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':shared:wasmPackageJson'.
> Could not resolve all dependencies for configuration ':shared:wasmNpm'.
   > Could not resolve org.jetbrains.compose.runtime:runtime:1.4.0.
     Required by:
         project :shared
      > No matching variant of org.jetbrains.compose.runtime:runtime:1.4.0 was found. The consumer was configured to find a library for use during 'kotlin-runtime', preferably optimized for non-jvm, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'wasm' but:
          - Variant 'debugApiElements-published' capability org.jetbrains.compose.runtime:runtime:1.4.0 declares a library:
              - Incompatible because this component declares a component for use during compile-time, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' and the consumer needed a component for use during 'kotlin-runtime', as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'wasm'
              - Other compatible attribute:
                  - Doesn't say anything about its target Java environment (preferred optimized for non-jvm)
          - Variant 'debugRuntimeElements-published' capability org.jetbrains.compose.runtime:runtime:1.4.0 declares a library for use during runtime:
              - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'wasm'
              - Other compatible attribute:
                  - Doesn't say anything about its target Java environment (preferred optimized for non-jvm)
          - Variant 'desktopApiElements-published' capability org.jetbrains.compose.runtime:runtime:1.4.0 declares a library:
              - Incompatible because this component declares a component for use during compile-time, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' and the consumer needed a component for use during 'kotlin-runtime', as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'wasm'
              - Other compatible attribute:
                  - Doesn't say anything about its target Java environment (preferred optimized for non-jvm)
And many more similar logs are there Help me please, I want to build an app for all android , ios, desktop and web in single project by sharing compose ui. Thanks
I am also getting this error in build section:
Copy code
Default configuration for Compose for Web is disabled: multiple Kotlin JS IR targets are defined. Specify Compose for Web Kotlin targets by using `compose.web.targets()`
a
Could not resolve org.jetbrains.compose.runtimeruntime1.4.0
No matching variant
I don’t think v1.4.0 has a WASM variant
s
Then which version of compose runtime has wasm variant?
o
Then which version of compose runtime has wasm variant?
1.4.0-dev-wasm06 or whatever version is used in ImageViewer example with k/wasm
s
Hi @Oleksandr Karpovich [JB], thanx, i missed that point maye, But now i changed that, it worked for web, But now it started failing for ios build, before web it was working for ios fine, getting following error now:
Copy code
> Task :shared:linkPodDebugFrameworkIosSimulatorArm64 FAILED
warning: Cannot infer a bundle ID from packages of source files and exported dependencies, use the bundle name instead: shared. Please specify the bundle ID explicitly using the -Xbinary=bundleId=<id> compiler flag.
error: Compilation failed: No file for /App|3770576908038690392[0]

 * Source files:
 * Compiler version info: Konan: 1.8.20 / Kotlin: 1.8.20
 * Output kind: FRAMEWORK

error: java.lang.IllegalStateException: No file for /App|3770576908038690392[0]
	at org.jetbrains.kotlin.backend.konan.serialization.KonanIrLinker$KonanPartialModuleDeserializer.getFileNameOf(KonanIrlinker.kt:500)
	at org.jetbrains.kotlin.backend.konan.serialization.KonanIrLinker.getExternalDeclarationFileName(KonanIrlinker.kt:435)
	at org.jetbrains.kotlin.backend.konan.DependenciesTrackerImpl$add$2.invoke(DependenciesTracker.kt:106)
	at org.jetbrains.kotlin.backend.konan.DependenciesTrackerImpl$add$2.invoke(DependenciesTracker.kt:105)
i am stuck with that, please help
o
1.4.0-dev-wasm.. builds are very experimental and it relies on experimental builds of some kotlin libs which were missing for k/native. if you want to run ios and web target I think your option could be to target k/js for now and use 1.4.0 version. Compose for Web (k/js) is experimental too. But at least 1.4.0 version is expected to work for ios and k/js.
s
Ok thnx, i will try removing wasm and only try with k/js with 1.4.0, and lets see how it goes.
Hi @Oleksandr Karpovich [JB], it worked for ios as well now with k/js only insread of wasm, But in web its not loading xml resource image from resources, copyJsResources workaround is also there for js,
Copy code
val copyJsResources = tasks.create("copyJsResourcesWorkaround", Copy::class.java) {
    from(project(":shared").file("src/commonMain/resources"))
    into("build/processedResources/js/main")
}
And i checked resource is being copied as well, But its not loading in web ui, i am using it like this in common code
Copy code
Image(
    painterResource("compose-multiplatform.xml"),
    null
)
Can you give me any suggestion for that., why its not loading image. Thanks
o
1.4.0 resources lib doesn’t yet support .xml images for web target. I think it should already work with 1.5.0-dev1043 version.
s
Ok thnx @Oleksandr Karpovich [JB] , and is it safe to use that? will it not break anything? Then i think we can try 1.5.0-alpha03 as well instead of 1.5.0-dev1043, will that also support xml images for web as there will be less chances of breaking something in alpha, am i right?
I think 1.5.0-alpha03 is available for android only, may be my mistake, so is it safe to use 1.5.0-dev1043?
o
1.5.0-dev1043 is a dev build which can be used to try out some fixes or new features for learning purpose. Such builds are not recommended for actual development.
s
ok thnku
i will try it
439 Views