You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Appium启动服务器时无法创建新会话,应用无法启动求助

Troubleshooting "A new session could not be created in Appium" Error When Launching Your App

Hey there, sorry to hear you're stuck with this frustrating Appium session error—totally understand how disheartening it is when you're just getting started! Since I don't have the exact details from your screenshots, let's walk through the most common fixes that resolve this "new session could not be created" issue.

1. Double-Check Your Desired Capabilities

This is the #1 culprit 90% of the time. Make sure all required capabilities are correctly configured (and case-sensitive!):

  • For Android:
    • platformName: Must be exactly Android
    • deviceName: Match the name shown in adb devices output
    • appPackage & appActivity: Confirm these are correct using aapt dump badging your-app.apk | grep package and aapt dump badging your-app.apk | grep launchable-activity
    • automationName: Set to UiAutomator2 (required for modern Android versions)
  • For iOS:
    • platformName: Must be exactly iOS
    • deviceName: Match the simulator/device name from xcrun simctl list devices
    • automationName: Set to XCUITest
    • udid: Required if using a real device

Example of valid Android capabilities:

desired_caps = {
    "platformName": "Android",
    "deviceName": "emulator-5554",
    "appPackage": "com.example.myapp",
    "appActivity": "com.example.myapp.MainActivity",
    "automationName": "UiAutomator2"
}

2. Verify Appium Server & Driver Setup

  • If you're using Appium 2.x, make sure you've installed the required driver via command line:
    # For Android
    appium driver install uiautomator2
    # For iOS
    appium driver install xcuitest
    
  • Confirm your test code is pointing to the correct Appium server URL: http://localhost:4723/wd/hub
  • Check that system dependencies are installed and in your PATH: Android SDK (with adb), Java JDK, Xcode (for iOS), etc.

3. Check Device/Emulator State

  • For Android: Run adb devices to confirm your device/emulator is in "device" state. If it's offline, restart the device or reset adb with:
    adb kill-server && adb start-server
    
  • For iOS: Ensure the simulator is running, or real devices are trusted (authorize in Settings > General > VPN & Device Management)
  • Close any other Appium instances or testing tools that might be using the device's automation session.

4. Dig Into Server Logs for Specific Errors

The generic "session could not be created" message hides the real issue. Look for specific lines in your server logs like:

Error: Could not find app package: com.example.myapp
Error: Failed to start WebDriverAgent on iOS device

These messages will directly point to the root cause—whether it's a missing app, incorrect capability, or driver permission issue.

5. Permissions & Security Checks

  • On Android: Ensure USB debugging is enabled on the device/emulator, and your app has any required runtime permissions (storage, location, etc.)
  • On iOS: For real devices, confirm you have a valid developer certificate and the app is signed correctly for testing.

If you're still stuck after trying these steps, sharing the exact error lines from your Appium server log and your full desired capabilities code will help narrow things down further!

内容的提问来源于stack exchange,提问作者Naveen

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 04:08:40