-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1.6.0 Resources are not packaged to Android file system #4503
Comments
#4487 there is a person already assigned for the issue, its because the resource library doesn't accept subfolders inside the main folders (files in this case) yet! If you put all files in the main folder it will work if im not wrong |
@PMARZV Thanks for your suggestions! But I think the issuse I encounterd is that the files under composeResources are not packaged to Android assets folder, as it should be done before version 1.6.0. Since I am loading the HTML file from the Android side, it needs to be packaged into its file system. |
It is implementation details that you should not rely on because it is a subject to change. We are going to provide an API to convert a resource to URI so you can use it from WebView (see this comment). |
@pjBooms Thanks to your reply! However, I am relying on native ability to implement the Before 1.6.0, I know that the resources under resources folder will be packaged to Android assets folder and then can be read by file system. I am just wondering how it works in 1.6.0? |
If we provide an API to convert a resource to URI won't it solve your problem? |
@pjBooms I don't think URI can solve the problem because we are not reading resources from common code. Instead, we rely on the native method of each platform to load the HTML file directly. For example, Android Webview provides the method |
I still cannot understand why URI does not work here. Does not Android Webview accept an arbitrary URL? |
@pjBooms Both Android and iOS WebView can accept arbitrary URLs, but they have different requirements for the URL format. In Android, the file needs to be located under the |
@pjBooms Are there updates on this issue? Actually, I just need to know how files under composeResources are packaged to the Android system. Will it be packaged into the Android assets folder? |
@pjBooms I was able to solve the issue by creating an However, I encountered another error in Kotlin 2.0 as mentioned in this issue. It appears that Kotlin 2.0 does not support a custom resource folder under the |
If your page uses other resources (e.g. images) it won't work. So, you may copy required content to the file system and use it as before by uri. |
I investigated the problem a bit: the Since you want to do it in a multiplatform application, you are suppose to use platform independent approach: extract required files to the file system and use it directly. Or, if it is required for the android only then you are able to use classic assets in the |
The PR changes the android resources packaging. Now all resources are packed to the android assets (not only fonts). It unblocks usage android URIs to the resources in a WebView or other external resource consumers. Additionally the PR fixes Android Studio Compose Previews work with multiplatform resources: ![](https://private-user-images.githubusercontent.com/3532155/341182790-ef26b667-ad0d-4efd-b7f9-23cff92ab49d.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTg4Nzg0MTgsIm5iZiI6MTcxODg3ODExOCwicGF0aCI6Ii8zNTMyMTU1LzM0MTE4Mjc5MC1lZjI2YjY2Ny1hZDBkLTRlZmQtYjdmOS0yM2NmZjkyYWI0OWQucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDYyMCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA2MjBUMTAwODM4WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9OTY1MzdhMTAxMjNmZDRhMDA4ZjdjODBjYzg3M2MyNDg0ZTA5OWFkZGZkZjk1ZDUwOWFkZDk3MmQ2YjIzNzJiYiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.xgUAr_2--ZHo6txhdAANRbe8ju2SQ5EACvK96gaGJnY) For a backward compatibility the resources library tries to read resources in java resources if assets were not found. Fixes #4877 Fixes #4503 Fixes #4932 Fixes #4476 ## Release Notes ### Features - Resources - Android Studio Preview works with Compose Multiplatform resources now - Compose Multiplatform resources are stored in the android assets now. This fixes such cases as a rendering resource files in WebViews or Media Players
I encountered the that issue in my CMP Webview library with CMP 1.6.0.
Previously, I would place the HTML files in the
commonMain/resources/assets
folder. This would automatically package the files into the Android assets folder, allowing us to load them using thewebView.loadUrl("file:///android_asset/$fileName")
method.However, after upgrading to 1.6.0, we moved the HTML files to the
commonMain/composeResources/files/asset
s folder, but got FILE_NOT_FOUND error.I am wondering how files will be packaged for other platforms (Android & iOS) in the new resources management system.
The text was updated successfully, but these errors were encountered: