Appium-Activity used to start app doesn't exist or cannot be launched! Make sure it exists and is a launchable activity

感情迁移 提交于 2019-12-11 04:56:47

问题


I am trying to run a test file created on eclipse using appium. When I execute the test on a real android device connected to the system, I get the following error:

Encountered internal error running the command:

Error: Error occurred while starting App.

Original error: Activity used to start app doesn't exist or cannot be launched! Make sure it exists and is a launchable activity.

The app opens fine manually and on the emulator so I'm not sure what's the issue with real devices.


回答1:


The issue speaks for itself: you either did not provide activity to recognise your app or you specified the wrong one.

What you can do:

  1. Connect device to laptop, make sure adb debugging is on
  2. Install your app manually and launch it
  3. In terminal run:

adb shell dumpsys window windows | grep -E 'mCurrentFocus|mFocusedApp'

  1. Check the output, you will get something like:

com.yourcompany.package/com.yourcompany.package.login.view.LoginActivity

So now you have package - com.yourcompany.package and activity com.yourcompany.package.login.view.LoginActivity that you should provide Appium.

  1. Add new capabilities, full set should look like: DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability("deviceName", "device"); capabilities.setCapability("app", pathToApk); capabilities.setCapability("platformName", "android"); capabilities.setCapability("appWaitPackage", "com.yourcompany.package"); capabilities.setCapability("appWaitActivity", "com.yourcompany.package.login.view.LoginActivity");

Works perfectly for me on multiple real devices




回答2:


Check manually Your app like @dmle said,

  1. Open app on Android
  2. go to terminal, console, command line (whatever)
  3. Adb should be installed,
  4. input in termninal adb shell dumpsys window windows | grep -E 'mCurrentFocus|mFocusedApp

The command will provide current package & activity.

Maybe developers changed You package id.




回答3:


I follow the guide here

  1. Type the following command to Terminal(not execute yet)

    adb shell dumpsys window windows | grep -E 'mCurrentFocus|mFocusedApp'

  2. Manually open app on device and execute the above command really quick to find the startActivity.

  3. Copy value of Package and Activity from mFocusedApp=

  4. Check the Activity start-able

    adb shell am start -n package.android/.activity.SplashActivity

  5. Set of Capabilities DesiredCapabilities capabilities = new DesiredCapabilities();

    capabilities.setCapability("device", "Android");
    capabilities.setCapability("platformName", "Android");
    capabilities.setCapability("deviceName", "Galaxy Note9");
    
    capabilities.setCapability("appWaitPackage", "package.android");
    capabilities.setCapability("appWaitActivity", ".activity.SplashActivity");
    capabilities.setCapability("appPackage", "package.android");
    capabilities.setCapability("appActivity", ".activity.SplashActivity");
    capabilities.setCapability("appWaitDuration", 10000);//this is way optional, 20000 by default
    
    capabilities.setCapability("app", newApp.getAbsolutePath());
    



回答4:


I always received "Encountered internal error running command: Error: The application at " "does not exist or is not accessible" I user a Driver wait and it solved.



来源:https://stackoverflow.com/questions/50360074/appium-activity-used-to-start-app-doesnt-exist-or-cannot-be-launched-make-sure

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!