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

AarImport does not import databinding package from aars leading to runtime crash. #13640

Open
arunkumar9t2 opened this issue Jul 2, 2021 · 2 comments
Labels
P2 We'll consider working on this in future. (Assignee optional) team-Android Issues for Android team type: bug

Comments

@arunkumar9t2
Copy link
Contributor

arunkumar9t2 commented Jul 2, 2021

Description of the problem / feature request:

When using aars via aar import, currently databinding package is not extracted and given to DatabindingV2Provider. This causes direct dependency pkgs to not have the package name and at runtime DatabindingMapper fails to find the Binding class.

Feature requests: what underlying problem are you trying to solve with this feature?

Runtime crash when consuming aar that contains databinding generated Binding classes.

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

  1. Create an AAR that has a layout xml file with databinding enabled
  2. Import the AAR into project and launch any screen that using the AAR layout's Binding class.
  3. Observe runtime crash.
java.lang.IllegalStateException: DataBindingUtil.inflate(…layout, container, false) must not be null

What operating system are you running Bazel on?

MacOs Catalina 10.15.7

What's the output of bazel info release?

release 4.1.0

If bazel info release returns "development version" or "(@non-git)", tell us how you built Bazel.

NA

What's the output of git remote get-url origin ; git rev-parse master ; git rev-parse HEAD ?

NA

Related info

According to this, the package name should be extracted from -br.bin file instead of the one from AndroidManifest.xml.

Related #2694

@arunkumar9t2 arunkumar9t2 changed the title Databinding does not import databinding package from aars leading to runtime crash. AarImport does not import databinding package from aars leading to runtime crash. Jul 2, 2021
@arunkumar9t2
Copy link
Contributor Author

Repro project:

databindingstrictdeps.zip

bazelisk build //app
./gradlew app:assembleDebug

Gradle generated DatabindingMapperImpl has correct packages imported from dependency. For example

  @Override
  public List<DataBinderMapper> collectDependencies() {
    ArrayList<DataBinderMapper> result = new ArrayList<DataBinderMapper>(1);
    result.add(new androidx.databinding.library.baseAdapters.DataBinderMapperImpl());
    return result;
  }

Bazel generated

  @Override
  public List<DataBinderMapper> collectDependencies() {
    ArrayList<DataBinderMapper> result = new ArrayList<DataBinderMapper>(1);
    result.add(new DataBinderMapperImpl());
    return result;
  }

Notice androidx.databinding.library.baseAdapters.DataBinderMapperImpl() is missing on Bazel generated file. This causes java.lang.IllegalStateException: DataBindingUtil.inflate(…layout, container, false) must not be null at runtime.

@arunkumar9t2
Copy link
Contributor Author

hi @ahumesky I am willing to work on this but I am stuck. It seems the package needs to be passed to provider here, we could compute it by inspecting the aar in an action, however I am not sure how to pass result of an action to a provider.

According to databinding implementation the package name must be extracted by -br.bin file inside the aar.

Any thoughts appreciated.

@ahumesky ahumesky added P2 We'll consider working on this in future. (Assignee optional) and removed untriaged labels Oct 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 We'll consider working on this in future. (Assignee optional) team-Android Issues for Android team type: bug
Projects
None yet
Development

No branches or pull requests

3 participants