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

Compose Preview Support #6315

Open
wants to merge 11 commits into
base: google
Choose a base branch
from

Conversation

idanakav
Copy link
Contributor

Resolves #2765

Add support for Compose Preview in Android Studio, main changes are:

  • Introduce a new ClassFileFinder, optimized for faster class lookups
  • Support reading and routing Android assets, such as fonts from the plugin aspect and pass them to Android Studio to be used in the rendering

Tested with the latest stable version, Iguana (23.2), it scales well even for our larger apps, I also did a sanity test and got the preview working in the compose sample in rules kotlin.

Known gaps:

  • Missing tests
  • No support for versions older than 23.2

Possible future improvements:

  • More optimizations BinaryTargetClassFileFinder, perhaps storing a map of package name -> target keys during sync could help
  • Fix additional functionalities, including preview run configurations

- Add DefaultMavenArtifactLocator
- Update BlazeClassJarProvider to return all of the external libraries
  in the workspace module case
We now read all of the dependencies in the workspace module case
Android assets are expected to be routed to Android Studio through `NamedIdeaSourceProvider::withAssetsDirectoryUrls` in order to be loaded later on by `StudioAssetFileOpener` which is used by Compose Preview.
A new `ClassFileFinder` inspired by `RenderJarClassFileFinder`.

This finder uses binary target
dependencies to locate the class file and is better optimized for large projects.
@idanakav
Copy link
Contributor Author

Also related: #6086

@sgowroji sgowroji added type: feature request product: Android Studio Android Studio plugin awaiting-maintainer Awaiting review from Bazel team on issues labels Mar 23, 2024
@sgowroji sgowroji added awaiting-user-response Awaiting response from author on PRs and removed awaiting-maintainer Awaiting review from Bazel team on issues labels Mar 28, 2024
@sgowroji
Copy link
Member

@idanakav Could you please take a look at the failing checks?

Summary:
The new logic will improve the fqcn lookups when no binary targets are listed in the project view.

For example, previously, we only checked for the package name cache for binary targets.

Test Plan:

1.
```
bazel build //aswb:aswb_bazel_zip --define=ij_product=android-studio-oss-latest-stable

INFO: Found 1 target...
Target //aswb:aswb_bazel_zip up-to-date:
  bazel-bin/aswb/aswb_bazel.zip
INFO: Elapsed time: 45.834s, Critical Path: 16.35s
INFO: 15 processes: 1 internal, 9 darwin-sandbox, 5 worker.
INFO: Build completed successfully, 15 total actions
```

2. Verify the Compose preview works with no binary targets are added in the project view, previously they would timeout

Reviewers: #ldap_go-code-admin, #ldap_ide-team, #ldap_java-devx, #ldap_mobile-platform-android, oliviern

Reviewed By: #ldap_mobile-platform-android, oliviern

Revert Plan: Revert diff

JIRA Issues: MOBDROID-5587

Differential Revision: https://code.uberinternal.com/D13499555
Summary: In the last lookup, we need to iterate all of the jars/target keys.

Test Plan: bazel build //aswb:aswb_bazel_zip --define=ij_product=android-studio-oss-latest-stable

Reviewers: #ldap_go-code-admin, #ldap_ide-team, #ldap_java-devx, #ldap_mobile-platform-android, oliviern

Reviewed By: #ldap_mobile-platform-android, oliviern

Revert Plan: Revert diff

JIRA Issues: MOBDROID-5587

Differential Revision: https://code.uberinternal.com/D13569575
@nkoroste
Copy link
Contributor

nkoroste commented Jun 3, 2024

any updates on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-user-response Awaiting response from author on PRs product: Android Studio Android Studio plugin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants