Skip to content
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

Pack all resources to assets on the android target. #4965

Merged
merged 13 commits into from
Jun 20, 2024
Merged

Conversation

terrakok
Copy link
Collaborator

@terrakok terrakok commented Jun 13, 2024

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:

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
Fixes #3828

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

@terrakok terrakok requested a review from igordmn June 13, 2024 15:37
@sergeshustoff
Copy link

I might be wrong here, but it looks like it might lead to fixing android previews with multiplatform resources (#4932, #4476) eventually... If CopyResourcesToAndroidAssetsTask is run before whatewer Android Studio does to render previews and AndroidContextProvider.ANDROID_CONTEXT is set somehow from the preview (or ContextLocal is used instead)

@terrakok
Copy link
Collaborator Author

terrakok commented Jun 17, 2024

I checked a preview with the new packaging but it doesn't work because android assets is semi available in the preview mode. It works strange for a regular android project too:

  1. Assets are not available unless you run the project first time.
  2. Assets are only available in the same module where your preview is.

UPDATE: the problem is addGeneratedSourceDirectory function doesn't work with AS Compose Preview :feelsgood:

ISSUE: https://issuetracker.google.com/348208777

@terrakok
Copy link
Collaborator Author

Now Android Studio Compose Preview works :godmode:

image

@AhmedTawfek
Copy link

AhmedTawfek commented Jun 24, 2024

Now Android Studio Compose Preview works :godmode:

image

Sorry for the question, but Iam currently having these versions in my compose multiplaform project, what versions do I need to use in case of solving the preview issues in AS ?

compose-plugin = "1.6.11" androidx-compose = "1.6.8" kotlin = "1.9.23" jetbrainsCompose = { id = "org.jetbrains.compose", version.ref = "compose-plugin" } androidx-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling", version.ref = "androidx-compose" } androidx-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview", version.ref = "androidx-compose" }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment