0

i have written simple script, which launches an chrome app on Android N(7.0),but not able to run, getting error

Details Environment

Appium version (or git revision) that exhibits the issue: 1.4.16.1
Last Appium version that did not exhibit the issue (if applicable): N/A
Desktop OS/version used to run Appium: window 7/32 bit
Node.js version (unless using Appium.app|exe): node-v8.9.4-x86
Mobile platform/version under test: chrome browser /64.0.3282.123
Real device or emulator/simulator:Android 7.0.0:MotoG(4)/Build/NPJS25.93-14-10
Appium CLI or Appium.app|exe: Appium Desktop exe

Error logs

info: [debug] Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: Command failed: C:\Windows\system32\cmd.exe /s /c "D:\android-sdk\platform-tools\adb.exe -s ZY2239HZB2 install "C:\Program Files (x86)\Appium\node_modules\appium\build\unlock_apk\unlock_apk-debug.apk""\nadb: failed to install C:\Program Files (x86)\Appium\node_modules\appium\build\unlock_apk\unlock_apk-debug.apk: Failure [INSTALL_FAILED_ALREADY_EXISTS: Attempt to re-install io.appium.unlock without first uninstalling.]\r\n)","killed":false,"code":1,"signal":null,"cmd":"C:\Windows\system32\cmd.exe /s /c "D:\android-sdk\platform-tools\adb.exe -s ZY2239HZB2 install "C:\Program Files (x86)\Appium\node_modules\appium\build\unlock_apk\unlock_apk-debug.apk""","origValue":"Command failed: C:\Windows\system32\cmd.exe /s /c "D:\android-sdk\platform-tools\adb.exe -s ZY2239HZB2 install "C:\Program Files (x86)\Appium\node_modules\appium\build\unlock_apk\unlock_apk-debug.apk""\nadb: failed to install C:\Program Files (x86)\Appium\node_modules\appium\build\unlock_apk\unlock_apk-debug.apk: Failure [INSTALL_FAILED_ALREADY_EXISTS: Attempt to re-install io.appium.unlock without first uninstalling.]\r\n"},"sessionId":null}

code:

import java.net.MalformedURLException;
import java.net.URL;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.remote.MobileCapabilityType;
import org.openqa.selenium.By;
import org.openqa.selenium.Platform;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.BrowserType;
import org.openqa.selenium.remote.DesiredCapabilities;
//import org.testng.annotations.Test;

public class StartChrome
{

public static void main(String[] args) throws MalformedURLException{

DesiredCapabilities cd=DesiredCapabilities.android();

cd.setCapability(MobileCapabilityType.BROWSER_NAME,BrowserType.CHROME);

cd.setCapability(MobileCapabilityType.PLATFORM,Platform.ANDROID);

// we need to define platform name
cd.setCapability(MobileCapabilityType.PLATFORM_NAME,"Android");

// Set the device name as well (you can give any name)
cd.setCapability(MobileCapabilityType.DEVICE_NAME,"my phone");

// set the android version as well
cd.setCapability(MobileCapabilityType.VERSION,"7.0");

// Create object of URL class and specify the appium server address
URL url= new URL("http://127.0.0.1:4723/wd/hub");

// Create object of AndroidDriver class and pass the url and capability that we created
WebDriver driver = new AndroidDriver(url, cd);

// Open url
driver.get("http://www.facebook.com");

// print the title
System.out.println("Title "+driver.getTitle());

// enter username
driver.findElement(By.name("email")).sendKeys("sni****@gmail.com");

// enter password
driver.findElement(By.name("pass")).sendKeys("*****8");

// click on submit button
driver.findElement(By.id("u_0_5")).click();

// close the browser
driver.quit();

1 Answer 1

1

Please update your Appium version as it's very old and you're seeing a known issue with Android 7.0 that was resolved in 1.6.0 (released October 2016).

If that's not possible, run the following commands before running your script:

adb -s device_serial uninstall io.appium.settings  
adb -s device_serial uninstall io.appium.unlock 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.