Skip to main content
Kofax

ImageProcessor fails with java.lang.NullPointerException Attempt to invoke virtual method android.content.Context android.content.Context.getApplicationContext null object

3018555

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

 

 

  • Was this article helpful?