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);
}
1

There are 1 answers

0
Lajos Arpad On

This is the line where the exception is thrown:

SVG svg = SVGParser.getSVGFromResource(getResources(), raw.canel);

There are two possibilities: either SVGParser is null and therefore has no getSVGFromResource, or raw is null and has no canel member.

If your error is that SVGParser is null, then the problem is that you did not import SVGParser. In this case the solution is to import the package which contains SVGParser, since it is a class and it was not imported, therefore the compiler thinks it is a variable and has not been initialized.

If your error is that raw is null, 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 after onCreate 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.