TakuSemba / Spotlight

Android Library that lights items for tutorials or walk-throughs etc...
Apache License 2.0
3.63k stars 363 forks source link

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

Open borjaruiz opened 4 years ago

borjaruiz commented 4 years ago

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 commented 4 years ago

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