Q:

Unable to click button on Mobile App in android

I am new of mobile app automation tested using Appium with TestNG.Am practicing to automate amazon app, App was launching successfully but when I try to click login option, it's getting: 

"FAILED: login org.openqa.selenium.NoSuchElementException: An
  element could not be located on the page using the given search
  parameters. (WARNING: The server did not provide any stacktrace
  information) Command duration or timeout: 0 milliseconds"

    public void login() throws InterruptedException{

        System.out.println("Login check");
        Thread.sleep(3000);
//      String sample = driver.findElementByXPath("//*[@class='android.widget.Button' and @index='5']").getText();
        System.out.println("Next sleep");

//      driver.findElement(By.xpath("//[@class='android.widget.Button' and @index='5']')]")).click();
//      driver.findElement(By.id("in.amazon.mShop.android.shopping:id/sign_in_button")).click();
        driver.findElement(By.xpath("//android.widget.Button[@index='5']")).click();
        Thread.sleep(3000);
        System.out.println("Pass");

    }

Image:

A:

"//android.widget.Button[@index='5']" is invalid xpath locator. If you will ever what to use index (but I strongly suggest not to do it), do it this way:
"(//android.widget.Button)[5]"
But in your case the best is to search by resource-id:
driver.findElement(By.id("sign_in_button")).click();

And if it still doesn't work you can print app screen xml structure just before you search for element:
System.out.println(driver.getPageSource())
Analyse the xml you get if it contains your button and what are the attributes of it.

