ERROR when install the apk applicaton with driver.install_app("xxx.apk")

Hey,
I am seeing some errors when I use the driver.install_app(“xxx.apk”).
I have been troubleshooting for a while, but would be really appreciate if someone can point me out the error.

caps = {}
caps["appium:deviceName"] = "emulator-5554"
caps["platformName"] = "android"
caps["appium:appPackage"] = "com.app.sample"
caps["appium:appActivity"] = "com.app.activity"
caps["appium:ensureWebviewsHavePages"] = True
caps["appium:nativeWebScreenshot"] = True
caps["appium:newCommandTimeout"] = 3600
caps["appium:connectHardwareKeyboard"] = True

driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", caps)
driver.install_app('/Users/blablacat/PycharmProjects/pythonProject/sample.apk')

File “/Users/blablacat/PycharmProjects/pythonProject/venv/lib/python3.9/site-packages/appium/webdriver/errorhandler.py”, line 26, in check_response
super().check_response(response)
File “/Users/blablacat/PycharmProjects/pythonProject/venv/lib/python3.9/site-packages/selenium/webdriver/remote/errorhandler.py”, line 243, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: Error executing adbExec. Original error: ‘Command ‘/Users/blablacat/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 install -r /Users/blablacat/PycharmProjects/pythonProject/sample.apk’ exited with code 1’; Command output: adb: failed to install /Users/blablacat/PycharmProjects/pythonProject/sample.apk: Failure [INSTALL_FAILED_INSUFFICIENT_STORAGE]

Stacktrace:
UnknownError: An unknown server-side error occurred while processing the command. Original error: Error executing adbExec. Original error: ‘Command ‘/Users/blablacat/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 install -r /Users/blablacat/PycharmProjects/pythonProject/sample.apk’ exited with code 1’; Command output: adb: failed to install /Users/blablacat/PycharmProjects/pythonProject/sample.apk: Failure [INSTALL_FAILED_INSUFFICIENT_STORAGE]

at getResponseForW3CError (/Applications/Appium Server GUI.app/Contents/Resources/app/node_modules/appium/node_modules/appium-base-driver/lib/protocol/errors.js:804:9)
at asyncHandler (/Applications/Appium Server GUI.app/Contents/Resources/app/node_modules/appium/node_modules/appium-base-driver/lib/protocol/protocol.js:380:37)

Process finished with exit code 1

1 Like

Might have to add some storage to your emulator. To see the adb command by itself try this in a terminal window:

/Users/blablacat/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 install -r /Users/blablacat/PycharmProjects/pythonProject/sample.apk

More info here:

I am seeing another error, I guess it is because I am trying to use the python code to install the .apk file. And when I load the webdriver.Remote, the app hasn’t install yet, so the emulator cannot find the app.

But I need to use the “driver” object to install the application, just wondering can you give me a suggestion on that?

driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", caps)
driver.install_app('/Users/blablacat/PycharmProjects/pythonProject/sample.apk')

ERROR
selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: ‘app’ option is required for reinstall
Stacktrace:
UnknownError: An unknown server-side error occurred while processing the command. Original error: ‘app’ option is required for reinstall
at getResponseForW3CError (/Applications/Appium Server GUI.app/Contents/Resources/app/node_modules/appium/node_modules/appium-base-driver/lib/protocol/errors.js:804:9)
at asyncHandler (/Applications/Appium Server GUI.app/Contents/Resources/app/node_modules/appium/node_modules/appium-base-driver/lib/protocol/protocol.js:380:37)

It would probably help to see the full log. I know you can skip ‘app’ capability when you have both appPackage and appActivity, however, you are skipping (according to your first post) both platformVersion and automationName. I’m honestly not sure what the side effects of that would be.

To read more about capabilities and what you need, read on here:

https://appium.io/docs/en/writing-running-appium/caps/

caps = {}
caps["appium:deviceName"] = "emulator-5554"
caps["platformName"] = "android"
caps["platformVersion"] = "12.0"
caps["automationName"] = "Appium"
caps["app"] = "/Users/blablacat/PycharmProjects/pythonProject/sample.apk'"
caps["appium:appPackage"] = "com.app.sample"
caps["appium:appActivity"] = "com.app.activity"
caps["appium:ensureWebviewsHavePages"] = True
caps["appium:nativeWebScreenshot"] = True
caps["appium:newCommandTimeout"] = 3600
caps["appium:connectHardwareKeyboard"] = True

driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", caps)
driver.install_app('/Users/blablacat/PycharmProjects/pythonProject/sample.apk')

I have now added the platform version, when I check on the emulator on Android Studio. It says version 12.0, hence I just fill in 12.0 there. For Automation name, I just put the “Appium” by default, I am not sure what are the rest. And also the “app” I just fill in the path with the .apk file, does it means as long as we fill in “app”, then it will automatically install the .apk from the path, and no need to use “driver.install_app”?

24

I perform “adb -s emulator-5554 install /Users/blablacat/PycharmProjects/pythonProject/ffsamples-debug.apk” on the mac terminal, and I am seeing Error below too, same as when running my code.

Full ERROR
/Users/blablacat/PycharmProjects/pythonProject/venv/bin/python /Users/blablacat/PycharmProjects/pythonProject/main.py
Start the appium application_log checking
Traceback (most recent call last):
File “/Users/blablacat/PycharmProjects/pythonProject/main.py”, line 51, in
main()
File “/Users/blablacat/PycharmProjects/pythonProject/main.py”, line 25, in main
driver = webdriver.Remote(“http://127.0.0.1:4723/wd/hub”, caps)
File “/Users/blablacat/PycharmProjects/pythonProject/venv/lib/python3.9/site-packages/appium/webdriver/webdriver.py”, line 230, in init
super().init(
File “/Users/blablacat/PycharmProjects/pythonProject/venv/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py”, line 272, in init
self.start_session(capabilities, browser_profile)
File “/Users/blablacat/PycharmProjects/pythonProject/venv/lib/python3.9/site-packages/appium/webdriver/webdriver.py”, line 320, in start_session
response = self.execute(RemoteCommand.NEW_SESSION, w3c_caps)
File “/Users/blablacat/PycharmProjects/pythonProject/venv/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py”, line 429, in execute
self.error_handler.check_response(response)
File “/Users/blablacat/PycharmProjects/pythonProject/venv/lib/python3.9/site-packages/selenium/webdriver/remote/errorhandler.py”, line 243, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: Error executing adbExec. Original error: ‘Command ‘/Users/blablacat/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 install /Users/blablacat/PycharmProjects/pythonProject/sample.apk’ exited with code 1’; Command output: adb: failed to install /Users/blablacat/PycharmProjects/pythonProject/sample.apk: Failure [INSTALL_FAILED_TEST_ONLY: installPackageLI]

Stacktrace:
UnknownError: An unknown server-side error occurred while processing the command. Original error: Error executing adbExec. Original error: ‘Command ‘/Users/blablacat/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 install /Users/blablacat/PycharmProjects/pythonProject/sample.apk’ exited with code 1’; Command output: adb: failed to install /Users/blablacat/PycharmProjects/pythonProject/sample.apk: Failure [INSTALL_FAILED_TEST_ONLY: installPackageLI]

at getResponseForW3CError (/Applications/Appium Server GUI.app/Contents/Resources/app/node_modules/appium/node_modules/appium-base-driver/lib/protocol/errors.js:804:9)
at asyncHandler (/Applications/Appium Server GUI.app/Contents/Resources/app/node_modules/appium/node_modules/appium-base-driver/lib/protocol/protocol.js:380:37)

Process finished with exit code 1

Try allowTestPackages capability: https://github.com/appium/appium-uiautomator2-driver#app

1 Like

Thanks a lot !!! It works when I set the caps[“allowTestPackages”] = True.
And also I just need to specify the “app” capability, then appium will help to install the application from the path, so I commented out the driver.install_app() function.

Thanks a lot for all the help! :slight_smile:

1 Like