ImageProcessor fails with java.lang.NullPointerException Attempt to invoke virtual method android.content.Context android.content.Context.getApplicationContext null object
Question / Problem:
When attempting to invoke the ImageProcessor constructor in our implementation, we are getting the following exception thrown:
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.Context android.content.Context.getApplicationContext()' on a null object reference
Answer / Solution:
In the source code for Android the customer wrote:
imageProcessor = new ImageProcessor();
and it failed with the reported error.
If you check the sample application ImageProcessor then you will see that you need to set the AppContextProvider before using the image processor like this:
@Override
protected void onCreate(Bundle savedInstanceState) {
// Initializing the SDK
AppContextProvider.setContext(getApplicationContext());
Afterwards it was working.
Applies to:
Product | Version |
---|---|
Mobile SDK | all |