-
Notifications
You must be signed in to change notification settings - Fork 213
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
Using more than one android resources library/directory, R not found #787
Comments
The root cause is due to You could fix it by either specifying different package name via This worked: android_library(
name = "resources_second",
manifest = "AndroidManifest.xml",
+ custom_package = "examples.android.lib.res",
resource_files = glob(["res-second/**"]),
visibility = ["//visibility:public"],
) |
The point is, we need two libraries with the same R class package and standard Bazel rules (android_library, or even android_binary) handle it gracefully by merging resources from different libraries on the same physical package as needed. That way, we can construct a library of any complexity and atomicity as we would imagine. |
…ixes bazelbuild#787 When two `kt_android_library` or `android_library` has the same package name either provided via `custom_package` or due to same package name in `AndroidManifest.xml`, R class fields from current module's resources were not compilable due to order of jars appearing in `--direct_dependencies`. This CL ensure the merged resources jar always comes first.
…ixes bazelbuild#787 When two `kt_android_library` or `android_library` has the same package name either provided via `custom_package` or due to same package name in `AndroidManifest.xml`, R class fields from current module's resources were not compilable due to order of jars appearing in `--direct_dependencies`. This CL ensure the merged resources jar always comes first.
…ixes bazelbuild#787 When two `kt_android_library` or `android_library` has the same package name either provided via `custom_package` or due to same package name in `AndroidManifest.xml`, R class fields from current module's resources were not compilable due to order of jars appearing in `--direct_dependencies`. This CL ensure the merged resources jar always comes first.
…ixes bazelbuild#787 When two `kt_android_library` or `android_library` has the same package name either provided via `custom_package` or due to same package name in `AndroidManifest.xml`, R class fields from current module's resources were not compilable due to order of jars appearing in `--direct_dependencies`. This CL ensure the merged resources jar always comes first.
In our project we use flat resources structure like
and BUILD.bazel like this:
One even could depend on some common resources from other packages if appropriate.
When trying to replace android_library definition in resource_user from example above with kotlin rules' kt_android_library (even not actually converting anything to kotlin at all and leaving a java file) and building the project, the kotlin compiler seems confused and can't find resource_files' R definitions that are linked in the [resource_user] library (but can find resources from the [resources_common] android library which is in its deps).
An error is as follows:
Might be related to some internal resource library not properly linked, but .params-0 .params-1 files for an example_fragment_kt-kt look A-OK to me (at least they have all the resources listed here).
Rules kotlin: 1.6.0
Bazel: 4.1.0, reproducible even on 5.2.0
Example which illustrates the case:
https://github.com/Nikolas-LFDesigns/kotlin-android-resources-example
Similar issues:
An issue bazelbuild/bazel#8109 sounds similar to me, but it was fixed eons ago (still, might be useful on triaging)
The text was updated successfully, but these errors were encountered: