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

The IDE Android resource link broken when the custom_package is not set #6563

Open
ivyspirit opened this issue Jul 10, 2024 · 0 comments
Open
Assignees
Labels
awaiting-maintainer Awaiting review from Bazel team on issues lang: kotlin Kotlin rules integration product: Android Studio Android Studio plugin type: bug

Comments

@ivyspirit
Copy link
Contributor

ivyspirit commented Jul 10, 2024

Description of the bug:

When define an Android library,

kt_android_library(
    name = "res_generated_lib",
    custom_package = "com.myPackage",
    manifest = "src/main/AndroidManifest.xml",
    resource_files = glob(
        ["src/main/res/**"],
        exclude = ["**/.DS_Store"],
    ),
    visibility = ["//visibility:public"],
)

If the custom_package = "com.myPackage", is not set, and if the BUILD file is under the root of your project dir, the rules_kotlin or rules_android will pass a null value to init the IntelljiInfo. This will cause the resource link/preview not working in the IDE.

For example: When hover over the R.color.xxx instead giving the color preview, it shows the generated R.class integer value. When click on the R.color.xxx it will navigate to the generated R class. The correct behavior is to show the color preview, and when click on the R.color.xxx it will navigate to the xml definition.

The proposed solution is: when the passed in javaPackage is null to IDE, use the package name defined in the AndroidManifest.xml to get the package name for resources.

The current behavior:
Screenshot 2024-07-10 at 11 16 05 AM

The expected behavior when hovering over the resource from Kotlin code:

Screenshot 2024-07-10 at 11 12 53 AM

Which category does this issue belong to?

No response

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

  1. Define kt_android_library with android resource and with resource and android manifest
  2. Define the bazel BUILD file under the root of the project dir.
  3. Reference the resource in your android code.
  4. Build. Then click on the generated R.xx in the code it will link to the java class file instead of xml file.

Which Intellij IDE are you using? Please provide the specific version.

Android Studio Iguana | 2023.2.1 Patch 2

What programming languages and tools are you using? Please provide specific versions.

Kotlin

What Bazel plugin version are you using?

v2024.03.26

Have you found anything relevant by searching the web?

No response

Any other information, logs, or outputs that you want to share?

No response

@ivyspirit ivyspirit added awaiting-maintainer Awaiting review from Bazel team on issues type: bug labels Jul 10, 2024
@iancha1992 iancha1992 added product: Android Studio Android Studio plugin product: IntelliJ IntelliJ plugin lang: java Java rules integration lang: kotlin Kotlin rules integration and removed product: IntelliJ IntelliJ plugin lang: java Java rules integration labels Jul 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-maintainer Awaiting review from Bazel team on issues lang: kotlin Kotlin rules integration product: Android Studio Android Studio plugin type: bug
Projects
None yet
Development

No branches or pull requests

5 participants