Getting Null pointer exception on AndroidDriver

Hi,
Iam getting null pointer exception while invoking swipe method …
Please see the code below
public void swipeDirection()
{
Dimension size = driver.manage().window().getSize();
//System.out.println(size);

	//Find startx point which is right side of screen.
	int startx = (int) (size.width *.80) ;
	
	//Find endx point which is left side of screen.
	int endX = (int) (size.width*.30);
	
	//Find starty point which is at bottom side of screen.
	int startY= (int) (size.height*.80);
	
	 //Find endy point which is at top side of screen.
	int endY = (int) (size.height * 0.20);

	AndroidDriver driver2 = new AndroidDriver(null)) ;
	driver2.swipe(startx, endY, startx, endY, 1000);
	//Swipe from top tp bottom

}

Here AndroidDriver takes null value by default… can anyone tell me how to fix this issue… Appreciate for your answer
Thanks

depending on java-client/appium version you are using endX and endY in swipe could be:

  • relative
  • absolute

Thanks Aleksei… Let me check through it…

What is the purpose of this statement? How are you creating driver?