I work with SVG format, added a library, all the methods recognized, did everything as in the example and then run NullPointerException
??
I can not understand why ...
Here is my onCreate method in Activity
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_camera);
RelativeLayout rlHumanBody = (RelativeLayout) findViewById(R.id.control);
\\But in this line error
SVG svg = SVGParser.getSVGFromResource(getResources(), R.raw.frontfigure);
Drawable drawable = svg.createPictureDrawable();
rlHumanBody.setBackground(drawable);
}
is such a mistake
FATAL EXCEPTION: main
Process: com.example.android.camera2basic, PID: 4396
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.
android.camera2basic/com.example.android.camera2basic.CameraActivity}:
com.applantation.android.svg.SVGParseException: java.lang.NullPointerException:
Attempt to invoke virtual method 'float java.lang.Float.floatValue()' on a null
object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java :903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Caused by: com.applantation.android.svg.SVGParseException: java.lang.
NullPointerException: Attempt to invoke virtual method 'float java.lang.Float.
floatValue()' on a null object reference
at com.applantation.android.svg.SVGParser.parse(SVGParser.java:211)
at com.applantation.android.svg.SVGParser.getSVGFromResource(SVGParser.java:1 10)
at com.example.android.camera2basic.CameraActivity.onCreate(CameraActivity.java:222)
the last line here indicates the line 222 is a line in my onCreate
method in which code and crashes.
What am I doing wrong?