When I launch my app this problem shows. This is my Java code:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(layout.activity_main);
ImageView imageView = new ImageView(this);
imageView.setBackgroundColor(Color.WHITE);
SVG svg = SVGParser.getSVGFromResource(getResources(), raw.canel);`
imageView.setImageDrawable(svg.createPictureDrawable());
setContentView(imageView);
}
This is the line where the exception is thrown:
There are two possibilities: either
SVGParser
isnull
and therefore has nogetSVGFromResource
, orraw
isnull
and has nocanel
member.If your error is that
SVGParser
isnull
, then the problem is that you did notimport
SVGParser
. In this case the solution is to import the package which containsSVGParser
, since it is aclass
and it was notimport
ed, therefore the compiler thinks it is a variable and has not been initialized.If your error is that
raw
isnull
, then the solution is to initialize it. In this case you have missed the part where the variable is being initialized. It is quite possible that you initialize it correctly, but afteronCreate
is being called, therefore the member is not initialized yet when you try to use it.We need more information about the problem to give you a more specific solution.