新手区 Appium Error: Bad app,cannot find the apk path

chen iju · 2017年03月23日 · 最后由 chen iju 回复于 2017年03月30日 · 2031 次阅读

初学者第一次发文,有什么建议直接说
Windows 8.1
Appium v1.4.16
error: Using local app, but didn't end in .zip, .ipa or .apk
是指我的名子有错误吗?

@Before
       public void setUp() throws Exception {
           // set up appiup
           File classpathRoot = new File(System.getProperty("user.dir"));
           File appDir = new File(classpathRoot, "src\\java\\apps\\ContactManager");
           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("app", "D:\\new project\\Appium_test20170303\\demotest\\src\\main\\java\\apps");
           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);
       }

這是 appium 日誌

> info: --> POST /wd/hub/session {"capabilities":{"desiredCapabilities":{"app":"D:\\new project\\Appium_test20170303\\demotest\\src\\main\\java\\apps","appPackage":"com.example.android.contactmanager","appActivity":".ContactManager","platformName":"Android","deviceName":"TEST","platformVersion":"4.4.2"},"requiredCapabilities":{}},"desiredCapabilities":{"app":"D:\\new project\\Appium_test20170303\\demotest\\src\\main\\java\\apps","appPackage":"com.example.android.contactmanager","appActivity":".ContactManager","platformName":"Android","deviceName":"TEST","platformVersion":"4.4.2"},"requiredCapabilities":{}}
> info: Client User-Agent string: Apache-HttpClient/4.5.2 (Java/1.8.0_112-release)
> error: Using local app, but didn't end in .zip, .ipa or .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:\new project\Appium_test20170303\demotest\src\main\java\apps. 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: Using local app, but didn't end in .zip, .ipa or .apk
> info: [debug] Error: Bad app: D:\new project\Appium_test20170303\demotest\src\main\java\apps. 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: Using local app, but didn't end in .zip, .ipa or .apk
>     at [object Object].<anonymous> (D:\appium\Appium\node_modules\appium\lib\devices\android\android-common.js:56:13)
>     at [object Object].Device.configureLocalApp (D:\appium\Appium\node_modules\appium\lib\devices\device.js:100:5)
>     at [object Object].Device.configureApp (D:\appium\Appium\node_modules\appium\lib\devices\device.js:68:10)
>     at [object Object].androidCommon.configureApp (D:\appium\Appium\node_modules\appium\lib\devices\android\android-common.js:76:35)
>     at [object Object].androidCommon.configure (D:\appium\Appium\node_modules\appium\lib\devices\android\android-common.js:37:10)
>     at [object Object].Appium.configure (D:\appium\Appium\node_modules\appium\lib\appium.js:250:15)
>     at [object Object].<anonymous> (D:\appium\Appium\node_modules\appium\lib\appium.js:118:10)
>     at [object Object].Appium.start (D:\appium\Appium\node_modules\appium\lib\appium.js:129:5)
>     at exports.createSession (D:\appium\Appium\node_modules\appium\lib\server\controller.js:188:16)
>     at Layer.handle [as handle_request] (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\layer.js:82:5)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:110:13)
>     at Route.dispatch (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:91:3)
>     at Layer.handle [as handle_request] (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\layer.js:82:5)
>     at D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\index.js:267:22
>     at Function.proto.process_params (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\index.js:321:12)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\index.js:261:10)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:100:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at D:\appium\Appium\node_modules\appium\lib\server\controller.js:39:7
>     at Layer.handle [as handle_request] (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\layer.js:82:5)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:110:13)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at Route.dispatch (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:91:3)
>     at Layer.handle [as handle_request] (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\layer.js:82:5)
>     at D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\index.js:267:22
>     at Function.proto.process_params (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\index.js:321:12)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\index.js:261:10)
>     at methodOverride (D:\appium\Appium\node_modules\appium\node_modules\method-override\index.js:79:5)
>     at Layer.handle [as handle_request] (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\layer.js:82:5)
>     at trim_prefix (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\index.js:302:13)
>     at D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\index.js:270:7
>     at Function.proto.process_params (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\index.js:321:12)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\index.js:261:10)
>     at logger (D:\appium\Appium\node_modules\appium\node_modules\morgan\index.js:136:5)
>     at Layer.handle [as handle_request] (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\layer.js:82:5)
>     at trim_prefix (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\index.js:302:13)
>     at D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\index.js:270:7
>     at Function.proto.process_params (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\index.js:321:12)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\index.js:261:10)
>     at D:\appium\Appium\node_modules\appium\node_modules\body-parser\lib\read.js:111:5
>     at done (D:\appium\Appium\node_modules\appium\node_modules\body-parser\node_modules\raw-body\index.js:248:14)
> info: [debug] Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: Bad app: D:\\new project\\Appium_test20170303\\demotest\\src\\main\\java\\apps. 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: Using local app, but didn't end in .zip, .ipa or .apk)","origValue":"Bad app: D:\\new project\\Appium_test20170303\\demotest\\src\\main\\java\\apps. 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: Using local app, but didn't end in .zip, .ipa or .apk"},"sessionId":null}
> error: Unexpected error: Error: Can't set headers after they are sent.
>     at ServerResponse.OutgoingMessage.setHeader (_http_outgoing.js:335:11)
>     at ServerResponse.header (D:\appium\Appium\node_modules\appium\node_modules\express\lib\response.js:695:10)
>     at ServerResponse.send (D:\appium\Appium\node_modules\appium\node_modules\express\lib\response.js:146:12)
>     at ServerResponse.json (D:\appium\Appium\node_modules\appium\node_modules\express\lib\response.js:235:15)
>     at ServerResponse.send (D:\appium\Appium\node_modules\appium\node_modules\express\lib\response.js:134:21)
>     at D:\appium\Appium\node_modules\appium\lib\server\helpers.js:42:21
>     at safely (D:\appium\Appium\node_modules\appium\lib\server\helpers.js:306:5)
>     at module.exports.catchAllHandler (D:\appium\Appium\node_modules\appium\lib\server\helpers.js:41:3)
>     at Layer.handle_error (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\layer.js:58:5)
>     at trim_prefix (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\index.js:300:13)
>     at D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\index.js:270:7
>     at Function.proto.process_params (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\index.js:321:12)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\index.js:261:10)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:100:14)
>     at Layer.handle [as handle_request] (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\layer.js:84:5)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:110:13)
>     at Route.dispatch (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:91:3)
>     at Layer.handle [as handle_request] (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\layer.js:82:5)
>     at D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\index.js:267:22
>     at Function.proto.process_params (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\index.js:321:12)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\index.js:261:10)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:100:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at D:\appium\Appium\node_modules\appium\lib\server\controller.js:39:7
>     at Layer.handle [as handle_request] (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\layer.js:82:5)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:110:13)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at Route.dispatch (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:91:3)
> info: <-- POST /wd/hub/session 500 29.669 ms - 674 
>     at D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\index.js:267:22
>     at Function.proto.process_params (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\index.js:321:12)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\index.js:261:10)
>     at methodOverride (D:\appium\Appium\node_modules\appium\node_modules\method-override\index.js:79:5)
>     at Layer.handle [as handle_request] (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\layer.js:82:5)
>     at trim_prefix (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\index.js:302:13)
>     at D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\index.js:270:7
>     at Function.proto.process_params (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\index.js:321:12)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\index.js:261:10)
>     at logger (D:\appium\Appium\node_modules\appium\node_modules\morgan\index.js:136:5)
>     at Layer.handle [as handle_request] (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\layer.js:82:5)
>     at trim_prefix (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\index.js:302:13) context: [POST /wd/hub/session {"capabilities":{"desiredCapabilities":{"app":"D:\\new project\\Appium_test20170303\\demotest\\src\\main\\java\\apps","appPackage":"com.example.android.contactmanager","appActivity":".ContactManager",]
> TypeError: Cannot set property 'onResetTimeout' of null
>     at [object Object].Appium.configure (D:\appium\Appium\node_modules\appium\lib\appium.js:252:30)
>     at [object Object].<anonymous> (D:\appium\Appium\node_modules\appium\lib\appium.js:118:10)
>     at [object Object].Appium.start (D:\appium\Appium\node_modules\appium\lib\appium.js:129:5)
>     at exports.createSession (D:\appium\Appium\node_modules\appium\lib\server\controller.js:188:16)
>     at Layer.handle [as handle_request] (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\layer.js:82:5)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:110:13)
>     at Route.dispatch (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:91:3)
>     at Layer.handle [as handle_request] (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\layer.js:82:5)
>     at D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\index.js:267:22
>     at Function.proto.process_params (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\index.js:321:12)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\index.js:261:10)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:100:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at D:\appium\Appium\node_modules\appium\lib\server\controller.js:39:7
>     at Layer.handle [as handle_request] (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\layer.js:82:5)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:110:13)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at Route.dispatch (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\route.js:91:3)
>     at Layer.handle [as handle_request] (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\layer.js:82:5)
>     at D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\index.js:267:22
>     at Function.proto.process_params (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\index.js:321:12)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\index.js:261:10)
>     at methodOverride (D:\appium\Appium\node_modules\appium\node_modules\method-override\index.js:79:5)
>     at Layer.handle [as handle_request] (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\layer.js:82:5)
>     at trim_prefix (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\index.js:302:13)
>     at D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\index.js:270:7
>     at Function.proto.process_params (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\index.js:321:12)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\index.js:261:10)
>     at logger (D:\appium\Appium\node_modules\appium\node_modules\morgan\index.js:136:5)
>     at Layer.handle [as handle_request] (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\layer.js:82:5)
>     at trim_prefix (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\index.js:302:13)
>     at D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\index.js:270:7
>     at Function.proto.process_params (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\index.js:321:12)
>     at next (D:\appium\Appium\node_modules\appium\node_modules\express\lib\router\index.js:261:10)
>     at D:\appium\Appium\node_modules\appium\node_modules\body-parser\lib\read.js:111:5
>     at done (D:\appium\Appium\node_modules\appium\node_modules\body-parser\node_modules\raw-body\index.js:248:14)
>     at IncomingMessage.onEnd (D:\appium\Appium\node_modules\appium\node_modules\body-parser\node_modules\raw-body\index.js:294:7)
>     at IncomingMessage.g (events.js:199:16)
>     at IncomingMessage.emit (events.js:104:17)
>     at _stream_readable.js:908:16
>     at process._tickDomainCallback (node.js:381:11)
共收到 6 条回复 时间 点赞

路径不对

fdeferf 回复

感谢回复,但是路径哪里错了

capabilities.setCapability("app", app.getAbsolutePath());
capabilities.setCapability("app", "D:\\new project\\Appium_test20170303\\demotest\\src\\main\\java\\apps");

两个 app 的路径参数,重复了

fdeferf 回复

是重複了,但是问题还是在....

@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 
chen iju 回复

提示说明还是路径问题,把参数提过来

fdeferf 回复

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

@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);
        }
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册