'Adb failed to install apk in PyCharm

I am a MacOS user, and I am trying to access a specific activity within an app (the app is the APK file). The emulator I am running from Android Studio is Pixel 3a XL. I am using the Appium GUI server to run the code and using Pycharm to write the code. Prior to running the Appium GUI server, Android emulator, and PyCharm code, I was using a different APK file then switched to a new one. I typed in the command, 'appium-doctor --android' to verify that my environment variables and adb is correct and there were checkmarks indicating that it was. After switching to an updated APK file, I received an error stating that the adb failed to install the APK. Attached are the images of the errors and code.

Original error:

'Command '/Users/AaryanGoel/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 install /Users/aaryangoel/Downloads/app-debug-signed-2-21-22.apk' exited with code 1'; Stderr: 'adb: failed to install /Users/aaryangoel/Downloads/app-debug-signed-2-21-22.apk: Failure [INSTALL_FAILED_TEST_ONLY: installPackageLI]'; Code: '1'

Let me know if any other information is needed.

Our code:

from appium import webdriver

desired_capabilities = { "deviceName": "Pixel_3a_XL",

"platformName": "Android",
"appActivity":".SplashScreenActivity",

"appPackage":"edu.psu.hhd.hdfs.jpm165.genericsurveyapp2",

"app":"/Users/aaryangoel/Downloads/app-debug-signed-2-21-22.apk"

}

#Driver Instance webdriver.Remote("http://localhost:4723/wd/hub", desired_capabilities)


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source