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

java.lang.IllegalArgumentException: Cannot add a null child view to a ViewGroup #104

Open
borjaruiz opened this issue Sep 16, 2020 · 1 comment

Comments

@borjaruiz
Copy link

borjaruiz commented Sep 16, 2020

Version 2.0.2

java.lang.IllegalArgumentException: Cannot add a null child view to a ViewGroup
at android.view.ViewGroup.addView(ViewGroup.java:4952)
at android.view.ViewGroup.addView(ViewGroup.java:4917)
at com.takusemba.spotlight.SpotlightView.startTarget(SpotlightView.kt:116)
at com.takusemba.spotlight.Spotlight.showTarget(Spotlight.kt:96)

Tried many things without success. I'm using java and in a Fragment
myView is found using Butterknife, and if I put a breakpoint before starting spotlight, it's not null

private List getTargets() {
List targets = new ArrayList<>();
targets.add(new Target.Builder().setAnchor(myView).setShape(new Circle(100f)).build());
return targets;
}

@OverRide
public void onViewCreated(View view, @nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
new Spotlight.Builder(getActivity()).setTargets(getTargets()).build().start;
}

@borjaruiz
Copy link
Author

I just saw that if I put a .setOverlay(layout) it works fine.
I don't understand why it's mandatory to use a layout, furthermore it would be great to return a clearer exception message

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant