Native App and Browser is not Launching

I Am new to Appium. I was doing for Coding for Launching the Chrome Browser and Native App But I got “SessionNotCreatedException” Exception. Can anyone Guide me where I have done Mistake
PFB more details

Console Output

[Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: An unknown server-side error occurred while processing the command. (Original error: unknown error: Failed to clear data for com.android.chrome on device ccdcb242: Error: java.lang.SecurityException: PID 31419 does not have permission android.permission.CLEAR_APP_USER_DATA to clear data of package com.android.chrome]/

Program

import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.remote.DesiredCapabilities;
import io.appium.java_client.android.AndroidDriver;
public class launchWebApp {
public static void main(String[] args) throws MalformedURLException, InterruptedException {
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(“automationName”, “Appium”);
cap.setCapability(“platformName”, “Android”);
cap.setCapability(“platformVersion”,“6.0.1”);
cap.setCapability(“browserName”, “Chrome”);
cap.setCapability(“deviceName”, “ccdcb242”);

AndroidDriver driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"),cap);
driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
driver.get("http://m.sears.com/home");
Thread.sleep(5000);

driver.quit();
}
}

Appium Server Logs

info: [debug] Responding to client with error: {“status”:33,“value”:{“message”:“A new session could not be created. (Original error: An unknown server-side error occurred while processing the command. (Original error: unknown error: Failed to clear data for com.android.chrome on device ccdcb242: Error: java.lang.SecurityException: PID 31016 does not have permission android.permission.CLEAR_APP_USER_DATA to clear data of package com.android.chrome\r\n\n (Driver info: chromedriver=2.18.343845 (73dd713ba7fbfb73cbb514e62641d8c96a94682a),platform=Windows NT 6.1 SP1 x86_64)))”,“status”:13,“value”:{“message”:“unknown error: Failed to clear data for com.android.chrome on device ccdcb242: Error: java.lang.SecurityException: PID 31016 does not have permission android.permission.CLEAR_APP_USER_DATA to clear data of package com.android.chrome\r\n\n (Driver info: chromedriver=2.18.343845 (73dd713ba7fbfb73cbb514e62641d8c96a94682a),platform=Windows NT 6.1 SP1 x86_64)”},“httpCode”:200,“origValue”:“An unknown server-side error occurred while processing the command. (Original error: unknown error: Failed to clear data for com.android.chrome on device ccdcb242: Error: java.lang.SecurityException: PID 31016 does not have permission android.permission.CLEAR_APP_USER_DATA to clear data of package com.android.chrome\r\n\n (Driver info: chromedriver=2.18.343845 (73dd713ba7fbfb73cbb514e62641d8c96a94682a),platform=Windows NT 6.1 SP1 x86_64))”},“sessionId”:null}

For me also the same error is coming!
while launching chrome browser error is-PID 27236 does not have permission android.permission.CLEAR_APP_USER_DATA to clear data of package com.android.chrome

and regarding native -app is opening but error is unable to identify element

configurations-WIN 7-64 bit
Appium-1.4.13.1
chrome browser-56.x
device-redmi MI prime 2s
chrome driver 2.28
Note-previously it was working fine please help

Hello I found the solution to it.
Just upgraded the appium to the latest version and explicitly gave the chromedriver bin path in appium
apart from that please check the developer tools security options ,please ensure them to be checked.
for me checked ones are-
USB debugging
USB debugging(Security settings)
Enable OEM unlock

others are
stay awake

hope it helps issue is solved :slight_smile:

Thanks Shruti.
It’s working after changing security setting

Hi Shruthi,
How to give the chrome-driver path explicitly?
which path i have to give my mac machine driver or mobile?

Rahil,
How do u configured the driver info?

Hi Raj Mohan

In the appium console we can set the path of chromedriver
Else System.setProperty(“webdriver.chrome.driver”,"path
here ");

IN DesiredCapabilities also we can give

shruthi_mishra,

am using mac to execute the script and have connected the android mobile. while running the below codes am getting the error like "Original error: unknown error: Failed to clear data for com.android.chrome on device d37c9b79: Error: java.lang.SecurityException: PID 27002 does not have permission android.permission.CLEAR_APP_USER_DATA to clear data of package com.android.chrome"

Please help me to fix this issue, am new to mobile automation.
Note: In simulator my script was ran successfully but in real mobile am facing this issue

			DesiredCapabilities capabilities = new DesiredCapabilities();
			capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, Platform.ANDROID);
		    capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "6.0.1");
		    capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "d37c9b79");
		    capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, MobileBrowserType.CHROME);
		    capabilities.setCapability("appPackage", "com.android.chrome");
		    capabilities.setCapability("appActivity", "com.google.android.apps.chrome.Main");
			capabilities.setCapability("noReset", true);
			webDriver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities); 
            webDriver.get("myURL");

The error says that script is unable to clear the chrome cache . I am also facing the same issue in my Redmi Mi 2s prime.Lets see if anyone can help to solve this error.