Skip to main content
Kofax

ImageProcessor creation fails with java.lang.NullPointerException

Article # 3035465 - Page views: 7

Article # 3035465 - Page views: 7

Issue

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

 

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.

 

Level of Complexity 

Moderate

 

Applies to  

Product Version Build Environment Hardware
Kofax Mobile SDK all      

References

Add any references to other internal or external articles

 

  • Was this article helpful?