使用appium在android手机上连接应用程序时发生错误

我是最近在这里学习appium的,虽然我设置了所有需要的信息,但出现错误。这是app日志:使用appium在android手机上连接应用程序时发生错误

[debug] [ADB] Running 'D:\Android\sdk\platform-tools\adb.exe' with args: ["- 

P",5037,"-s","ZY223MPGDF","shell","am","force-stop","io.appium.unlock"]

[debug] [AndroidDriver] Not cleaning generated files. Add `clearSystemFiles`

capability if wanted.

[MJSONWP] Encountered internal error running command: Error: Error occured

while starting App. Original error: Error executing adbExec. Original error:

'Command 'D\:\\Android\\sdk\\platform-tools\\adb.exe -P 5037 -s ZY223MPGDF

shell am start -W -n ai.zuoye.app/com.homework.app.activity.HomeActivity -S

-a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f

0x10200000' exited with code 1'; Stderr: 'java.lang.SecurityException:

Permission Denial: starting Intent { act=android.intent.action.MAIN cat=

[android.intent.category.LAUNCHER] flg=0x10200000

cmp=ai.zuoye.app/com.homework.app.activity.HomeActivity } from null

(pid=9092, uid=2000) not exported from uid 10213

at android.os.Parcel.readException(Parcel.java:1684)

at android.os.Parcel.readException(Parcel.java:1637)

at android.app.ActivityManagerProxy.startActivityAndWait(ActivityManagerNative.java:3282)

at com.android.commands.am.Am.runStart(Am.java:634)

at com.android.commands.am.Am.onRun(Am.java:390)

at com.android.internal.os.BaseCommand.run(BaseCommand.java:51)

at com.android.commands.am.Am.main(Am.java:122)

at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)

at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:262)'; Code: '1'

at Object.wrappedLogger.errorAndThrow (../../lib/logging.js:63:13)

at ADB.callee$0$0$ (../../../lib/tools/apk-utils.js:101:9)

at tryCatch (C:\Users\Glority\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40)

at GeneratorFunctionPrototype.invoke [as _invoke] (C:\Users\Glority\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:315:22)

at GeneratorFunctionPrototype.prototype.(anonymous function) [as throw] (C:\Users\Glority\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:100:21)

at GeneratorFunctionPrototype.invoke (C:\Users\Glority\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37)

at <anonymous>

at process._tickCallback (internal/process/next_tick.js:160:7)

[HTTP] <-- POST /wd/hub/session 500 31691 ms - 1369

我看到它说权限否认,但我可以用它来启动手机计算器,我不知道这一点。 这是我的代码:

import os 

import sys

import unittest

from time import sleep

from appium import webdriver

class hh (unittest.TestCase):

def test_addContent(self):

desire_caps={}

desire_caps['platformName']='Android'

desire_caps['platformVersion']='7.1.1'

desire_caps['appPackage']='ai.zuoye.app'

desire_caps['appActivity']='com.homework.app.activity.HomeActivity'

desire_caps['deviceName']='ZY223MPGDF'

driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub",desire_caps)

sleep(10)

driver.quit()

if __name__ == "__main__":

suite = unittest.TestLoader().loadTestsFromTestCase(hh)

unittest.TextTestRunner(verbosity=2).run(suite)

谢谢!

回答:

检查几件事情

1)确保你的开发人员选项是和USB调试选项启用

2)检查是否ü可以通过ADB命令

3打开手机的应用程序)检查你的设备是否通过运行命令adb设备授权..如果它说未经授权使其授权

以上是 使用appium在android手机上连接应用程序时发生错误 的全部内容, 来源链接: utcz.com/qa/264326.html

回到顶部