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

Android public.xml dimen resource crash #5077

Closed
menny opened this issue Apr 23, 2018 · 6 comments
Closed

Android public.xml dimen resource crash #5077

menny opened this issue Apr 23, 2018 · 6 comments

Comments

@menny
Copy link
Contributor

menny commented Apr 23, 2018

Description of the problem / feature request:

When building an Android library that also provides a public.xml file, the resource merging action will crash with a NullPointerException with:

SEVERE: Unexpected
java.lang.NullPointerException
	at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:871)
	at com.google.common.collect.SingletonImmutableSet.<init>(SingletonImmutableSet.java:45)
	at com.google.common.collect.ImmutableSet.of(ImmutableSet.java:84)
	at com.google.common.collect.ImmutableSet.construct(ImmutableSet.java:166)
	at com.google.common.collect.ImmutableSet.copyOf(ImmutableSet.java:269)
	at com.google.devtools.build.android.PlaceholderIdFieldInitializerBuilder.chooseTypeIds(PlaceholderIdFieldInitializerBuilder.java:381)
	at com.google.devtools.build.android.PlaceholderIdFieldInitializerBuilder.build(PlaceholderIdFieldInitializerBuilder.java:354)
	at com.google.devtools.build.android.AndroidResourceClassWriter.flush(AndroidResourceClassWriter.java:91)
	at com.google.devtools.build.android.UnwrittenMergedAndroidData.writeResourceClass(UnwrittenMergedAndroidData.java:91)
	at com.google.devtools.build.android.AndroidResourceMerger.mergeData(AndroidResourceMerger.java:94)
	at com.google.devtools.build.android.AndroidResourceMerger.mergeData(AndroidResourceMerger.java:195)
	at com.google.devtools.build.android.AndroidResourceMergingAction.main(AndroidResourceMergingAction.java:236)
	at com.google.devtools.build.android.ResourceProcessorBusyBox$Tool$7.call(ResourceProcessorBusyBox.java:97)
	at com.google.devtools.build.android.ResourceProcessorBusyBox.main(ResourceProcessorBusyBox.java:188)

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

I have constructed a repro project at https://github.com/menny/bazel_android_public_dimen
running bazel build //:hello_world will result in a Bazel crash.

What operating system are you running Bazel on?

macoOS

What's the output of bazel info release?

release 0.12.0- (@non-git)

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

I built it locally by fetching the 0.12 tag and calling ./compile.sh

Have you found anything relevant by searching the web?

I have not seen any similar issues.

@jin
Copy link
Member

jin commented Apr 23, 2018

cc @ahumesky @asteinb

@asteinb
Copy link
Contributor

asteinb commented Apr 23, 2018

You're running into two issues here. First, our code seems to have a bug where it won't process a public XML file correctly if it has no entries. I'll put in a fix for that.

However, even with that fix, this sort of public XML file is a feature from Gradle that isn't currently supported in Bazel. Even if we handled it properly here (you could work around it here, for example, by adding an entry to the public.xml file), aapt wouldn't be able to deal with it.

bazel-io pushed a commit that referenced this issue Apr 23, 2018
This should provide more understandable behavior in the case described in
#5077

RELNOTES: none
PiperOrigin-RevId: 193968203
@menny
Copy link
Contributor Author

menny commented Apr 23, 2018

@asteinb will this comit be available in the 0.13 release?

@asteinb
Copy link
Contributor

asteinb commented Apr 23, 2018

@ahumesky

@jin
Copy link
Member

jin commented Apr 23, 2018

0.13.0 baseline has been cut, but I'll ask for this commit to be cherrypicked.

meteorcloudy pushed a commit that referenced this issue Apr 24, 2018
This should provide more understandable behavior in the case described in
#5077

RELNOTES: none
PiperOrigin-RevId: 193968203
meteorcloudy pushed a commit that referenced this issue Apr 26, 2018
This should provide more understandable behavior in the case described in
#5077

RELNOTES: none
PiperOrigin-RevId: 193968203
meteorcloudy pushed a commit that referenced this issue Apr 26, 2018
This should provide more understandable behavior in the case described in
#5077

RELNOTES: none
PiperOrigin-RevId: 193968203
@jin
Copy link
Member

jin commented May 1, 2018

Closing this issue as the commit has been cherry picked into 0.13.0.

@jin jin closed this as completed May 1, 2018
meteorcloudy pushed a commit that referenced this issue May 7, 2018
This should provide more understandable behavior in the case described in
#5077

RELNOTES: none
PiperOrigin-RevId: 193968203
luca-digrazia pushed a commit to luca-digrazia/DatasetCommitsDiffSearch that referenced this issue Sep 4, 2022
    This should provide more understandable behavior in the case described in
    bazelbuild/bazel#5077

    RELNOTES: none
    PiperOrigin-RevId: 193968203
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants