• 路径问题解决了,我改成这样
    感谢你

    @Before
            public void setUp() throws Exception {
                // set up appiup
                File appDir = new File("D:\\NewProject\\newproject\\Appium_test20170303\\demotest\\src\\main\\java\\apps");
                File app = new File( appDir, "ContactManager.apk");
                DesiredCapabilities capabilities = new DesiredCapabilities();
                capabilities.setCapability("deviceName","TEST");
                capabilities.setCapability("platformVersion", "4.4.2");
                capabilities.setCapability("app", app.getAbsolutePath());
                capabilities.setCapability("appPackage", "com.example.android.contactmanager");
                capabilities.setCapability("appActivity", ".ContactManager");
                driver = new AndroidDriver<>(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
            }
    
  • 是重複了,但是问题还是在....

    @Before
            public void setUp() throws Exception {
                // set up appiup
                File classpathRoot = new File(System.getProperty("user.dir"));
                File appDir = new File(classpathRoot, "src\\main\\java\\apps");
                File app = new File(appDir, "ContactManager.apk");
                DesiredCapabilities capabilities = new DesiredCapabilities();
                capabilities.setCapability("deviceName","TEST");
                capabilities.setCapability("platformVersion", "4.4.2");
                capabilities.setCapability("app", app.getAbsolutePath());
                capabilities.setCapability("appPackage", "com.example.android.contactmanager");
                capabilities.setCapability("appActivity", ".ContactManager");
                driver = new AndroidDriver<>(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
            }
    
    > info: Client User-Agent string: Apache-HttpClient/4.5.2 (Java/1.8.0_112-release)
    > info: [debug] Using local app from desired caps: D:\NewProject\newproject\Appium_test20170303\src\main\java\apps\ContactManager.apk
    > info: [debug] Got configuration error, not starting session
    > info: [debug] Cleaning up appium session
    > error: Failed to start an Appium session, err was: Error: Bad app: D:\NewProject\newproject\Appium_test20170303\src\main\java\apps\ContactManager.apk. App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name. cause: Error: Error locating the app: ENOENT, stat 'D:\NewProject\newproject\Appium_test20170303\src\main\java\apps\ContactManager.apk'
    > info: [debug] Error: Bad app: D:\NewProject\newproject\Appium_test20170303\src\main\java\apps\ContactManager.apk. App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name. cause: Error: Error locating the app: ENOENT, stat 'D:\NewProject\newproject\Appium_test20170303\src\main\java\apps\ContactManager.apk'
    >     at [object Object].<anonymous> (D:\appium\Appium\node_modules\appium\lib\devices\android\android-common.js:56:13)
    >     at D:\appium\Appium\node_modules\appium\lib\devices\device.js:82:16
    >     at FSReqWrap.oncomplete (fs.js:95:15)
    > info: [debug] Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: Bad app: D:\\NewProject\\newproject\\Appium_test20170303\\src\\main\\java\\apps\\ContactManager.apk. App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name. cause: Error: Error locating the app: ENOENT, stat 'D:\\NewProject\\newproject\\Appium_test20170303\\src\\main\\java\\apps\\ContactManager.apk')","origValue":"Bad app: D:\\NewProject\\newproject\\Appium_test20170303\\src\\main\\java\\apps\\ContactManager.apk. App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name. cause: Error: Error locating the app: ENOENT, stat 'D:\\NewProject\\newproject\\Appium_test20170303\\src\\main\\java\\apps\\ContactManager.apk'"},"sessionId":null}
    > info: <-- POST /wd/hub/session 500 7.590 ms - 868 
    
  • 感谢回复,但是路径哪里错了

  • 請問樓主解決了嗎? 我也遇到這個問題

    error: Failed to start an Appium session, err was: Error: Bad app: D:\new project\Appium_test20170303\demotest\scr\main\java\apps\ContactManager.apk. App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name. cause: Error: Error locating the app: ENOENT, stat 'D:\new project\Appium_test20170303\demotest\scr\main\java\apps\ContactManager.apk'