Not able to run appium on my new android device due to error code 4294967177

I am running appium on windows machine but couldn’t able to execute the appium script because of below issue :

“adb.exe -P 5037 -s fd76a805 shell ime enable io.appium.android.ime/.UnicodeIME’ exited with code 4294967177’; Stderr: ‘’; Code: ‘4294967177’”

Appium version : 1.9
Mobile Device : Redmi Y2 (Android version : 8.1.0)
Windows 7

Please find below stacktrace from Eclipse console

org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Error executing adbExec. Original error: ‘Command ‘C:\User1\My_Project_Data\adt-bundle-windows-x86_64\adt-bundle-windows-x86_64-20131030\sdk\platform-tools\adb.exe -P 5037 -s fd76abbcd shell ime enable io.appium.android.ime/.UnicodeIME’ exited with code 4294967177’; Stderr: ‘’; Code: ‘4294967177’ (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 13.34 seconds
Build info: version: ‘2.53.0’, revision: ‘35ae25b’, time: ‘2016-03-15 16:57:40’
System info: host: ‘MYPC’, ip: ‘192.16.22.80’, os.name: ‘Windows 7’, os.arch: ‘amd64’, os.version: ‘6.1’, java.version: ‘1.7.0_80’
Driver info: io.appium.java_client.android.AndroidDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:40)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:249)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:131)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:144)
at io.appium.java_client.DefaultGenericMobileDriver.(DefaultGenericMobileDriver.java:36)
at io.appium.java_client.AppiumDriver.(AppiumDriver.java:114)
at io.appium.java_client.AppiumDriver.(AppiumDriver.java:132)
at io.appium.java_client.android.AndroidDriver.(AndroidDriver.java:92)
at root.LocalDriverFactory.createMobileInstance(LocalDriverFactory.java:53)
at root.WebDriverListener.beforeInvocation(WebDriverListener.java:40)
at org.testng.internal.invokers.InvokedMethodListenerInvoker$InvokeBeforeInvocationWithoutContextStrategy.callMethod(InvokedMethodListenerInvoker.java:84)
at org.testng.internal.invokers.InvokedMethodListenerInvoker.invokeListener(InvokedMethodListenerInvoker.java:62)
at org.testng.internal.Invoker.runInvokedMethodListeners(Invoker.java:552)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:617)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:816)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1124)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
at org.testng.TestRunner.privateRun(TestRunner.java:774)
at org.testng.TestRunner.run(TestRunner.java:624)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:359)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:354)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:312)
at org.testng.SuiteRunner.run(SuiteRunner.java:261)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1215)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1140)
at org.testng.TestNG.run(TestNG.java:1048)
at root.TestNGMain.cfnDriver(TestNGMain.java:78)
at root.MachineThread.run(Driver.java:31)

Please find below Appium logs

[35m[Appium][39m Welcome to Appium v1.9.1
[35m[Appium][39m Appium REST http interface listener started on 0.0.0.0:4723
[35m[HTTP][39m [37m-->[39m [37mPOST[39m [37m/wd/hub/session[39m
[35m[HTTP][39m [90m{"desiredCapabilities":{"appActivity":"host.exp.exponent.experience.ShellAppActivity","PlatformVersion":"7.0","udid":"fd76abcd","appPackage":"com.abc","DriverPort":"4723","ModuleName":"abcApp","noReset":false,"platformName":"Android","deviceName":"Y2","appWaitActivity":"host.exp.exponent.experience.ShellAppActivity","unicodeKeyboard":true,"resetKeyboard":true,"DriverIP":"0.0.0.0","autoGrantPermissions":true}}[39m
[debug] [35m[MJSONWP][39m Calling AppiumDriver.createSession() with args: [{"appActivity":"host.exp.exponent.experience.ShellAppActivity","PlatformVersion":"7.0","udid":"fd76abcd","appPackage":"com.abc","DriverPort":"4723","ModuleName":"abcApp","noReset":false,"platformName":"Android","deviceName":"Y2","appWaitActivity":"host.exp.exponent.experience.ShellAppActivity","unicodeKeyboard":true,"resetKeyboard":true,"DriverIP":"0.0.0.0","autoGrantPermissions":true},null,null]
[debug] [35m[BaseDriver][39m Event 'newSessionRequested' 
[35m[Appium][39m Creating new AndroidDriver (v4.1.1) session
[35m[Appium][39m Capabilities:
[35m[Appium][39m   appActivity: host.exp.exponent.experience.ShellAppActivity
[35m[Appium][39m   PlatformVersion: 7.0
[35m[Appium][39m   udid: fd76abcd
[35m[Appium][39m   appPackage: com.abc
[35m[Appium][39m   DriverPort: 4723
[35m[Appium][39m   ModuleName: abcApp
[35m[Appium][39m   noReset: false
[35m[Appium][39m   platformName: Android
[35m[Appium][39m   deviceName: Y2
[35m[Appium][39m   appWaitActivity: host.exp.exponent.experience.ShellAppActivity
[35m[Appium][39m   unicodeKeyboard: true
[35m[Appium][39m   resetKeyboard: true
[35m[Appium][39m   DriverIP: 0.0.0.0
[35m[Appium][39m   autoGrantPermissions: true
[debug] [35m[BaseDriver][39m Creating session with MJSONWP desired capabilities: {"appActivity":"host.exp.ex...
[35m[BaseDriver][39m The following capabilities were provided, but are not recognized by appium: PlatformVersion, DriverPort, ModuleName, DriverIP.
[35m[BaseDriver][39m Session created with session id: 92527bf5-e83d-4548-aed0-d122b93603f1
[35m[AndroidDriver][39m Java version is: 1.8.0_151

[35m[ADB][39m Checking whether adb is present
[35m[ADB][39m Cannot sort build-tools folders ["19.1.0","27.0.3","28.0.0","android-4.4"] by semantic version names.
[35m[ADB][39m Falling back to sorting by modification date. Original error: Invalid Version: android-4.4
[35m[ADB][39m Found 4 'build-tools' folders under 'C:\User1\My_Project_Data\adt-bundle-windows-x86_64\adt-bundle-windows-x86_64-20131030\sdk' (newest first):
[35m[ADB][39m     C:/User1/My_Project_Data/adt-bundle-windows-x86_64/adt-bundle-windows-x86_64-20131030/sdk/build-tools/27.0.3
[35m[ADB][39m     C:/User1/My_Project_Data/adt-bundle-windows-x86_64/adt-bundle-windows-x86_64-20131030/sdk/build-tools/28.0.0
[35m[ADB][39m     C:/User1/My_Project_Data/adt-bundle-windows-x86_64/adt-bundle-windows-x86_64-20131030/sdk/build-tools/android-4.4
[35m[ADB][39m     C:/User1/My_Project_Data/adt-bundle-windows-x86_64/adt-bundle-windows-x86_64-20131030/sdk/build-tools/19.1.0
[35m[ADB][39m Using adb.exe from C:\User1\My_Project_Data\adt-bundle-windows-x86_64\adt-bundle-windows-x86_64-20131030\sdk\platform-tools\adb.exe
[35m[AndroidDriver][39m Retrieving device list
[debug] [35m[ADB][39m Trying to find a connected android device
[debug] [35m[ADB][39m Getting connected devices...
[debug] [35m[ADB][39m 1 device(s) connected
[35m[AndroidDriver][39m Using device: fd76abcd
[debug] [35m[ADB][39m Setting device id to fd76abcd
[debug] [35m[ADB][39m Running 'C:\User1\My_Project_Data\adt-bundle-windows-x86_64\adt-bundle-windows-x86_64-20131030\sdk\platform-tools\adb.exe -P 5037 -s fd76abcd shell getprop ro.build.version.sdk'
[debug] [35m[ADB][39m Current device property 'ro.build.version.sdk': 27
[debug] [35m[ADB][39m Device API level: 27
[35m[AndroidDriver][39m Consider setting 'automationName' capability to 'uiautomator2' on Android >= 6, since UIAutomator framework is not maintained anymore by the OS vendor.
[35m[AndroidDriver][39m App file was not listed, instead we're going to run com.abc directly on the device
[debug] [35m[AndroidDriver][39m Checking whether package is present on the device
[debug] [35m[ADB][39m Running 'C:\User1\My_Project_Data\adt-bundle-windows-x86_64\adt-bundle-windows-x86_64-20131030\sdk\platform-tools\adb.exe -P 5037 -s fd76abcd shell pm list packages com.abc'
[35m[AndroidDriver][39m Starting Android session
[debug] [35m[ADB][39m Running 'C:\User1\My_Project_Data\adt-bundle-windows-x86_64\adt-bundle-windows-x86_64-20131030\sdk\platform-tools\adb.exe -P 5037 -s fd76abcd wait-for-device'
[debug] [35m[ADB][39m Running 'C:\User1\My_Project_Data\adt-bundle-windows-x86_64\adt-bundle-windows-x86_64-20131030\sdk\platform-tools\adb.exe -P 5037 -s fd76abcd shell echo ping'
[debug] [35m[AndroidDriver][39m Pushing settings apk to device...
[debug] [35m[ADB][39m Getting install status for io.appium.settings
[debug] [35m[ADB][39m Running 'C:\User1\My_Project_Data\adt-bundle-windows-x86_64\adt-bundle-windows-x86_64-20131030\sdk\platform-tools\adb.exe -P 5037 -s fd76abcd shell pm list packages io.appium.settings'
[debug] [35m[ADB][39m App is not installed
[debug] [35m[ADB][39m App 'C:\Users\A684681\AppData\Roaming\npm\node_modules\appium\node_modules\io.appium.settings\app\build\outputs\apk\settings_apk-debug.apk' not installed. Installing
[debug] [35m[ADB][39m Device API level: 27
[debug] [35m[ADB][39m Running 'C:\User1\My_Project_Data\adt-bundle-windows-x86_64\adt-bundle-windows-x86_64-20131030\sdk\platform-tools\adb.exe -P 5037 -s fd76abcd install -g C\:\\Users\\A684681\\AppData\\Roaming\\npm\\node_modules\\appium\\node_modules\\io.appium.settings\\app\\build\\outputs\\apk\\settings_apk-debug.apk'
[debug] [35m[ADB][39m Running 'C:\User1\My_Project_Data\adt-bundle-windows-x86_64\adt-bundle-windows-x86_64-20131030\sdk\platform-tools\adb.exe -P 5037 -s fd76abcd install -g C\:\\Users\\A684681\\AppData\\Roaming\\npm\\node_modules\\appium\\node_modules\\io.appium.settings\\app\\build\\outputs\\apk\\settings_apk-debug.apk'
[35m[AndroidDriver][39m Ignored error while installing Appium Settings helper: 'Error executing adbExec. Original error: 'Command 'C\:\\User1\\My_Project_Data\\adt-bundle-windows-x86_64\\adt-bundle-windows-x86_64-20131030\\sdk\\platform-tools\\adb.exe -P 5037 -s fd76abcd install -g C\:\\Users\\A684681\\AppData\\Roaming\\npm\\node_modules\\appium\\node_modules\\io.appium.settings\\app\\build\\outputs\\apk\\settings_apk-debug.apk' exited with code 1'; Stderr: 'adb: failed to install C:\Users\A684681\AppData\Roaming\npm\node_modules\appium\node_modules\io.appium.settings\app\build\outputs\apk\settings_apk-debug.apk: Security exception: You need the android.permission.INSTALL_GRANT_RUNTIME_PERMISSIONS permission to use the PackageManager.INSTALL_GRANT_RUNTIME_PERMISSIONS flag

[35m[AndroidDriver][39m 

[35m[AndroidDriver][39m java.lang.SecurityException: You need the android.permission.INSTALL_GRANT_RUNTIME_PERMISSIONS permission to use the PackageManager.INSTALL_GRANT_RUNTIME_PERMISSIONS flag

[35m[AndroidDriver][39m     at com.android.server.pm.PackageInstallerService.createSessionInternal(PackageInstallerService.java:454)

[35m[AndroidDriver][39m     at com.android.server.pm.PackageInstallerService.createSession(Package'; Code: '1''. Manually uninstalling the application with package id 'io.appium.settings' may help. Expect some Appium features may not work as expected unless this problem is fixed.
[debug] [35m[ADB][39m Running 'C:\User1\My_Project_Data\adt-bundle-windows-x86_64\adt-bundle-windows-x86_64-20131030\sdk\platform-tools\adb.exe -P 5037 -s fd76abcd shell ps'
[debug] [35m[ADB][39m Device API level: 27
[debug] [35m[ADB][39m Running 'C:\User1\My_Project_Data\adt-bundle-windows-x86_64\adt-bundle-windows-x86_64-20131030\sdk\platform-tools\adb.exe -P 5037 -s fd76abcd shell am start -W -n io.appium.settings/.Settings -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000'
[35m[AndroidDriver][39m Failed to launch settings app: Cannot start the 'io.appium.settings' application. Visit https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/android/activity-startup.md for troubleshooting. Original error: Activity name '.Settings' used to start the app doesn't exist or cannot be launched! Make sure it exists and is a launchable activity
[debug] [35m[ADB][39m Device API level: 27
[debug] [35m[ADB][39m Running 'C:\User1\My_Project_Data\adt-bundle-windows-x86_64\adt-bundle-windows-x86_64-20131030\sdk\platform-tools\adb.exe -P 5037 -s fd76abcd shell appops set io.appium.settings android\:mock_location allow'
[debug] [35m[ADB][39m Running 'C:\User1\My_Project_Data\adt-bundle-windows-x86_64\adt-bundle-windows-x86_64-20131030\sdk\platform-tools\adb.exe -P 5037 -s fd76abcd shell appops set io.appium.settings android\:mock_location allow'
[35m[AndroidDriver][39m Unable to set mock location for app 'io.appium.settings': Error executing adbExec. Original error: 'Command 'C\:\\User1\\My_Project_Data\\adt-bundle-windows-x86_64\\adt-bundle-windows-x86_64-20131030\\sdk\\platform-tools\\adb.exe -P 5037 -s fd76abcd shell appops set io.appium.settings android\:mock_location allow' exited with code 4294967295'; Stderr: 'Error: No UID for io.appium.settings in user 0'; Code: '4294967295'
[35m[AndroidDriver][39m setDeviceLanguageCountry requires language or country.
[35m[AndroidDriver][39m Got language: 'null' and country: 'null'
[debug] [35m[Logcat][39m Starting logcat capture
[debug] [35m[AndroidDriver][39m Enabling Unicode keyboard support
[debug] [35m[AndroidDriver][39m Pushing unicode ime to device...
[debug] [35m[ADB][39m Running 'C:\User1\My_Project_Data\adt-bundle-windows-x86_64\adt-bundle-windows-x86_64-20131030\sdk\platform-tools\adb.exe -P 5037 -s fd76abcd install C\:\\Users\\A684681\\AppData\\Roaming\\npm\\node_modules\\appium\\node_modules\\appium-android-ime\\bin\\UnicodeIME-debug.apk'
[debug] [35m[ADB][39m Running 'C:\User1\My_Project_Data\adt-bundle-windows-x86_64\adt-bundle-windows-x86_64-20131030\sdk\platform-tools\adb.exe -P 5037 -s fd76abcd install C\:\\Users\\A684681\\AppData\\Roaming\\npm\\node_modules\\appium\\node_modules\\appium-android-ime\\bin\\UnicodeIME-debug.apk'
[debug] [35m[ADB][39m Application 'C:\Users\A684681\AppData\Roaming\npm\node_modules\appium\node_modules\appium-android-ime\bin\UnicodeIME-debug.apk' already installed. Continuing.
[debug] [35m[ADB][39m Running 'C:\User1\My_Project_Data\adt-bundle-windows-x86_64\adt-bundle-windows-x86_64-20131030\sdk\platform-tools\adb.exe -P 5037 -s fd76abcd shell settings get secure default_input_method'
[debug] [35m[AndroidDriver][39m Unsetting previous IME com.facemoji.lite.xiaomi/com.baidu.simeji.SimejiIME
[debug] [35m[AndroidDriver][39m Setting IME to 'io.appium.android.ime/.UnicodeIME'
[debug] [35m[ADB][39m Running 'C:\User1\My_Project_Data\adt-bundle-windows-x86_64\adt-bundle-windows-x86_64-20131030\sdk\platform-tools\adb.exe -P 5037 -s fd76abcd shell ime enable io.appium.android.ime/.UnicodeIME'
[debug] [35m[ADB][39m Running 'C:\User1\My_Project_Data\adt-bundle-windows-x86_64\adt-bundle-windows-x86_64-20131030\sdk\platform-tools\adb.exe -P 5037 -s fd76abcd shell ime enable io.appium.android.ime/.UnicodeIME'
[35m[Appium][39m Cannot retrieve git revision for Appium version 1.9.1 from GitHub. Original error: Error: connect ETIMEDOUT 192.30.253.117:443
[debug] [35m[AndroidDriver][39m Shutting down Android driver
[debug] [35m[AndroidDriver][39m Called deleteSession but bootstrap wasn't active
[debug] [35m[Logcat][39m Stopping logcat capture
[debug] [35m[ADB][39m Running 'C:\User1\My_Project_Data\adt-bundle-windows-x86_64\adt-bundle-windows-x86_64-20131030\sdk\platform-tools\adb.exe -P 5037 -s fd76abcd shell am force-stop io.appium.unlock'
[debug] [35m[AndroidDriver][39m Not cleaning generated files. Add `clearSystemFiles` capability if wanted.
[debug] [35m[BaseDriver][39m Event 'newSessionStarted' logged at 1542353564815 (13:02:44 GMT+0530 (India Standard Time))
[debug] [35m[MJSONWP][39m Encountered internal error running command: Error: Error executing adbExec. Original error: 'Command 'C\:\\User1\\My_Project_Data\\adt-bundle-windows-x86_64\\adt-bundle-windows-x86_64-20131030\\sdk\\platform-tools\\adb.exe -P 5037 -s fd76abcd shell ime enable io.appium.android.ime/.UnicodeIME' exited with code 4294967177'; Stderr: ''; Code: '4294967177'
[debug] [35m[MJSONWP][39m     at ADB.execFunc$ (C:\Users\A684681\AppData\Roaming\npm\node_modules\appium\node_modules\appium-adb\lib\tools\system-calls.js:327:13)
[debug] [35m[MJSONWP][39m     at tryCatch (C:\Users\A684681\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40)
[debug] [35m[MJSONWP][39m     at GeneratorFunctionPrototype.invoke [as _invoke] (C:\Users\A684681\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:315:22)
[debug] [35m[MJSONWP][39m     at GeneratorFunctionPrototype.prototype.(anonymous function) [as throw] (C:\Users\A684681\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:100:21)
[debug] [35m[MJSONWP][39m     at GeneratorFunctionPrototype.invoke (C:\Users\A684681\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37)
[35m[HTTP][39m [37m<-- POST /wd/hub/session [39m[31m500[39m [90m10692 ms - 457[39m
[35m[HTTP][39m [90m[39m
[35m[Appium][39m Received SIGINT - shutting down
Terminate batch job (Y/N)?

Check if you have enabled USB debugging on the device.

USB debugging is on, I feel there is a issue with my old android sdk :frowning: