I created a library that uses ViewStub and integrated it to my project. When I run the application I get java.lang.IllegalArgumentException: ViewStub must have a valid layoutResource
and just after Attempt to invoke virtual method 'void android.widget.ImageView.setImageResource(int)' on a null object reference
.
I created another project without that library but the exact same viewstub and it worked.
So I guess the library loads the ViewStub slower the the application. Correct me if I'm wrong.
Is there any approach/solution to load the ViewStub from the library ?
So I want to answer to my question to any one will face this problem in the future.
I just replaced the tag
<ViewStub>
by<include>
and added the layout to it like thisand then I setup the visibility depending of my needs like this (for example to the actionBar):
Hope this will help someone, somewhere.