Support version Android N

As you can see from my comments above, I had to modify adb.js as well in order to get it to work on Android N

Getting the following error in server logs when trying to run tests on Android 7.0, appium 1.6.3:

Bad parameters: BadParametersError: Parameters were incorrect. We wanted {"required":["desiredCapabilities"],"optional":["requiredCap‌​abilities","capabili‌​ties","sessionId","i‌​d","sessionId","id",‌​"sessionId","id"]} and you sent ["capabilities"]

This solution helped me in setting up Android 7 in Moto G4 plus. I had to modify the adb.js of Appium 1.14.16.1 on Windows 7. Thank you! Cheers!

Can you paste your adb.js file here.
I also have Moto G4 Plus but updating it with the code given above didn’t solve my problem.
Please help

harigovind or any experts in this group, how you guys are debugging appium javascripts(adb.js) with Appium code(language bindings)? Meaning when you are debugging how you control from Appium code to respective java scripts?

FYI… i am very new to these development technologies and debugging into each of these applications.

Here you go,

  1. Go to adb.js in the path ‘node_modules//appium/node_modules/appium-adb/lib/adb.js’
    *Find the below
    ADB.prototype.shell = function (cmd, cb) {
    if (cmd.indexOf(’"’) === -1) {
    cmd = ‘"’ + cmd + ‘"’;
    }
    var execCmd = ‘shell ’ + cmd;
    this.exec(execCmd, cb);
    };
    Append the below
    ADB.prototype.shell_grep = function (cmd, grep, cb) {
    if (cmd.indexOf(’"’) === -1) {
    cmd = ‘"’ + cmd + ‘"’;
    }
    var execCmd = 'shell ’ + cmd + '| grep ’ + grep;
    this.exec(execCmd, cb);
    };

2 Find the 'ADB.prototype.getPIDsByName ’ and replace the whole section

ADB.prototype.getPIDsByName = function (name, cb) {
logger.debug(“Getting all processes with '” + name + “’”);
this.shell_grep(“ps”, name, function (err, stdout) {
if (err) {
logger.debug(“No matching processes found”);
return cb(null, []);
}
var pids = [];
_.each(procs, function (proc) {
var match = /[^\t ]+[\t ]+([0-9]+)/.exec(proc);
if (match) {
pids.push(parseInt(match[1], 10));
}
});
if (pids.length !== procs.length) {
var msg = "Could not extract PIDs from ps output. PIDS: " +
JSON.stringify(pids) + ", Procs: " + JSON.stringify(procs);
return cb(new Error(msg));
}
cb(null, pids);
});
};

Hope this works :slight_smile:

1 Like

Hi Manasa,

After doing above step still getting below error:

info: [debug] executing cmd: C:\Data\AndriodSDK\sdk\platform-tools\adb.exe -s 00a9afcf9f9319ce forward tcp:4724 tcp:4724
info: [debug] Pushing appium bootstrap to device…
info: [debug] executing cmd: C:\Data\AndriodSDK\sdk\platform-tools\adb.exe -s 00a9afcf9f9319ce push “C:\Program Files (x86)\Appium\node_modules\appium\build\android_bootstrap\AppiumBootstrap.jar” /data/local/tmp/
info: [debug] Pushing settings apk to device…
info: [debug] executing cmd: C:\Data\AndriodSDK\sdk\platform-tools\adb.exe -s 00a9afcf9f9319ce install “C:\Program Files (x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk”
info: [debug] Stopping logcat capture
info: [debug] Logcat terminated with code null, signal SIGTERM
info: [debug] Sent shutdown command, waiting for UiAutomator to stop…
warn: UiAutomator did not shut down fast enough, calling it gone
info: [debug] Cleaning up android objects
info: [debug] Cleaning up appium session
error: Failed to start an Appium session, err was: Error: Command failed: C:\WINDOWS\system32\cmd.exe /s /c “C:\Data\AndriodSDK\sdk\platform-tools\adb.exe -s 00a9afcf9f9319ce install “C:\Program Files (x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk””
Failed to install C:\Program Files (x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk: Failure [INSTALL_FAILED_ALREADY_EXISTS: Attempt to re-install io.appium.settings without first uninstalling.]

info: [debug] Error: Command failed: C:\WINDOWS\system32\cmd.exe /s /c “C:\Data\AndriodSDK\sdk\platform-tools\adb.exe -s 00a9afcf9f9319ce install “C:\Program Files (x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk””
Failed to install C:\Program Files (x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk: Failure [INSTALL_FAILED_ALREADY_EXISTS: Attempt to re-install io.appium.settings without first uninstalling.]

at ChildProcess.exithandler (child_process.js:751:12)
at ChildProcess.emit (events.js:110:17)
at maybeClose (child_process.js:1016:16)
at Process.ChildProcess._handle.onexit (child_process.js:1088:5)

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 “C:\Data\AndriodSDK\sdk\platform-tools\adb.exe -s 00a9afcf9f9319ce install “C:\Program Files (x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk””\nFailed to install C:\Program Files (x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk: Failure [INSTALL_FAILED_ALREADY_EXISTS: Attempt to re-install io.appium.settings without first uninstalling.]\r\n)”,“killed”:false,“code”:1,“signal”:null,“cmd”:“C:\WINDOWS\system32\cmd.exe /s /c “C:\Data\AndriodSDK\sdk\platform-tools\adb.exe -s 00a9afcf9f9319ce install “C:\Program Files (x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk”””,“origValue”:“Command failed: C:\WINDOWS\system32\cmd.exe /s /c “C:\Data\AndriodSDK\sdk\platform-tools\adb.exe -s 00a9afcf9f9319ce install “C:\Program Files (x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk””\nFailed to install C:\Program Files (x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk: Failure [INSTALL_FAILED_ALREADY_EXISTS: Attempt to re-install io.appium.settings without first uninstalling.]\r\n”},“sessionId”:null}
info: <-- POST /wd/hub/session 500 9078.790 ms - 1333

Hi Manasa,

I followed you, however still not able to start app, getting following error : -

error: Unhandled error: ReferenceError: grep is not defined

at [object Object].ADB.shell (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:192:46)
at [object Object].<anonymous> (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:942:16)
at [object Object].<anonymous> (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:180:9)
at ChildProcess.exithandler (child_process.js:742:7)
at ChildProcess.emit (events.js:110:17)
at maybeClose (child_process.js:1016:16)
at Socket.<anonymous> (child_process.js:1184:11)
at Socket.emit (events.js:107:17)
at Pipe.close (net.js:484:11) context: [POST /wd/hub/session {"capabilities":{"desiredCapabilities":{"appPackage":"svf.viewlift.com.test","app":"C:\\Users\\bhuvnesh.sharma\\workspace\\SVFAN\\app\\svf_release_buiild_v_1.0.016.apk","platformVersion":"7.0","browse]

info: [debug] executing cmd: C:\Users\bhuvnesh.sharma\AppData\Local\Android\android-sdk\platform-tools\adb.exe -s ZY223P4F3Z kill-server
info: [debug] Getting connected devices…
info: [debug] executing cmd: C:\Users\bhuvnesh.sharma\AppData\Local\Android\android-sdk\platform-tools\adb.exe -s ZY223P4F3Z devices
info: [debug] 1 device(s) connected
info: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5)
info: [debug] executing cmd: C:\Users\bhuvnesh.sharma\AppData\Local\Android\android-sdk\platform-tools\adb.exe -s ZY223P4F3Z wait-for-device
error: Unhandled error: ReferenceError: grep is not defined
at [object Object].ADB.shell (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:192:46)
at [object Object]. (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:942:16)
at [object Object]. (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:180:9)
at ChildProcess.exithandler (child_process.js:742:7)
at ChildProcess.emit (events.js:110:17)
at maybeClose (child_process.js:1016:16)
at Process.ChildProcess._handle.onexit (child_process.js:1088:5) context: [POST /wd/hub/session {“capabilities”:{“desiredCapabilities”:{“appPackage”:“svf.viewlift.com.test”,“app”:“C:\Users\bhuvnesh.sharma\workspace\SVFAN\app\svf_release_buiild_v_1.0.016.apk”,“platformVersion”:“7.0”,"browse]
info: [debug] Sent shutdown command, waiting for UiAutomator to stop…
warn: UiAutomator did not shut down fast enough, calling it gone
info: [debug] Cleaning up android objects
info: [debug] Cleaning up appium session
error: Failed to start an Appium session, err was: Device did not become ready in 5 secs; are you sure it’s powered on?
info: [debug] undefined
info: [debug] Responding to client with error: {“status”:33,“value”:{“message”:“A new session could not be created.”,“origValue”:“Device did not become ready in 5 secs; are you sure it’s powered on?”},“sessionId”:null}
info: <-- POST /wd/hub/session 500 48930.688 ms - 171

Please help…

Anybody else getting this error ?

Thanks

@Bhuvnesh

Upgrade your Appium 1.6.3 it will work.

Hi Pradeep,

I am already using an updated version - 1.4.16.1 Further it shows no update.

Thankyou
Bhuvnesh

Hi harigovind ,

i am getting following error can you please help me?

Appium error:
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 “C:\Users\sama\AppData\Local\Android\sdk\platform-tools\adb.exe -s ZY223Q2RQ4 install “C:\Program Files (x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk””\nFailed to install C:\Program Files (x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk: Failure [INSTALL_FAILED_ALREADY_EXISTS: Attempt to re-install io.appium.settings without first uninstalling.]\r\n)”,“killed”:false,“code”:1,“signal”:null,“cmd”:“C:\WINDOWS\system32\cmd.exe /s /c “C:\Users\sama\AppData\Local\Android\sdk\platform-tools\adb.exe -s ZY223Q2RQ4 install “C:\Program Files (x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk”””,“origValue”:“Command failed: C:\WINDOWS\system32\cmd.exe /s /c “C:\Users\sama\AppData\Local\Android\sdk\platform-tools\adb.exe -s ZY223Q2RQ4 install “C:\Program Files (x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk””\nFailed to install C:\Program Files (x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk: Failure [INSTALL_FAILED_ALREADY_EXISTS: Attempt to re-install io.appium.settings without first uninstalling.]\r\n”},“sessionId”:null}

info: <-- POST /wd/hub/session 500 10006.968 ms - 1375

Error in eclips:
new session could not be created. (Original error: Command failed: C:\WINDOWS\system32\cmd.exe /s /c “C:\Users\sama\AppData\Local\Android\sdk\platform-tools\adb.exe -s ZY223Q2RQ4 install “C:\Program Files (x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk””
Failed to install C:\Program Files (x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk: Failure [INSTALL_FAILED_ALREADY_EXISTS: Attempt to re-install io.appium.settings without first uninstalling.]
) (WARNING: The server did not provide any stacktrace information)

This is code:
DesiredCapabilities capabilities=new DesiredCapabilities();
capabilities.setCapability(“deviceName”,“Moto G (4)”);
capabilities.setCapability(“platformVersion”,“7.0”);
capabilities.setCapability(“platformName”,“Android”);
capabilities.setCapability(“appPackage”,“com.whatsapp”);
capabilities.setCapability(“appActivity”,“com.whatsapp.Main”);

     dr=new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"),capabilities);

please help me for solving this issue.

Thanks.

Hi,
did you get your problem solved? I received same error message. Please help …

Hi,

No luck yet !!

Configuration:

Machine OS: Windows 7
Appium: 1.4.16.1

Apply same change instructed by @Manasa_Kashyap

try to install 1.6.3 from comman line

install 1.6.3 from comman line

I tried to uninstall Appium_Settings / Unlock before starting Appium, it bypass this error [Failure [INSTALL_FAILED_ALREADY_EXISTS: Attempt to re-install io.appium.settings without first uninstalling.]]

but facing another error [error: Failed to start an Appium session, err was: Error: Command failed: C:\Win
dows\system32\cmd.exe /s /c “C:\Users\xxx\AppData\Local\Android\sdk\platfor
m-tools\adb.exe -s ac51daff shell “ps ‘uiautomator’””]

then apply changes instructed by Manasa_Kashyap

a new session successfully created!

hope it helps, good luck!

Machine OS: Windows Server 2008 R2
Appium: 1.4.16.1

thanks to @willosser @Manasa_Kashyap

Does anyone know how to uninstall Appium_Settings.apk and Unlock.apk programmatically vs. manually run cmd every time?

2 Likes

We have our own adb library which includes a method to uninstall the app. This won’t work if you are using a device farm (e.g. BitBar, SauceLabs) because they don’t give you access to adb (and rightfully so, they want to protect their devices from malicious or unintentional hazardous actions). If you are testing your device in house, though, you can use this solution.

Alternately, you can dig through appium and enhance their interfaces so it uninstalls the app before installing if using Appium N

1 Like

@samadhan_kolhe have you tried this ? It should solve that error

1.6.3 should have a fix for it though.

Thanks @Donna @Manasa_Kashyap

2 Likes

Hello ,

Thank you so much.Its working.Thanks for your help.

I get the test phone connected to my dev machine. could you please share your customized uninstall the app method in adb library? Appreciate your help, thanks!