gpt4 book ai didi

android - 机器人框架 - Appium 库 : Security Exception while starting the application

转载 作者:太空狗 更新时间:2023-10-29 13:47:57 25 4
gpt4 key购买 nike

我想测试一个 android 应用程序,我必须使用 Robot Framework 和 Appium Library。由于我是 Robot Framework 的新手,我创建了一个演示应用程序和测试,它只是启动应用程序。但是,我在 appium 服务器上收到以下错误:

    [MJSONWP] Encountered internal error running command: Error: Cannot start the 'g
r.cosmote.testcosmoteidsdk' application. Original error: Error executing adbExec
. Original error: 'Command 'C\:\\Users\\usl014\\AppData\\Local\\Android\\Sdk\\pl
atform-tools\\adb.exe -P 5037 -s emulator-5554 shell am start -W -n gr.cosmote.t
estcosmoteidsdk/gr.cosmote.testcosmoteidsdk.activities.HomeActivity -S -a androi
d.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000' exited w
ith code 4294967295'; Stderr: 'Security exception: Permission Denial: starting I
ntent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] fl
g=0x10200000 cmp=gr.cosmote.testcosmoteidsdk/.activities.HomeActivity } from nul
l (pid=9049, uid=2000) not exported from uid 10081
[MJSONWP]
[MJSONWP] java.lang.SecurityException: Permission Denial: starting Intent { act=
android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000
cmp=gr.cosmote.testcosmoteidsdk/.activities.HomeActivity } from null (pid=9049,
uid=2000) not exported from uid 10081
[MJSONWP] at com.android.server.am.ActivityStackSupervisor.checkStartAnyAc
tivityPermission(ActivityStackSupervisor.java:1632)
[MJSONWP] at com.android.server.am.ActivityStarter.startActivity(ActivityS
tarter.java:438)
[MJSONWP] at com.android.server.am.ActivityStarter.startActivityLocked(Act
ivityStarter.java:278)
[MJSONWP] at com.android.server.am.ActivityStarter.startActivityMayWait(Ac
tivityStarter.java:817)
[MJSONWP] at com.android.server.am.ActivityManagerService.startActivityAnd
Wait(ActivityManagerService.java:4625)
[MJSONWP] at com.android.server.am.ActivityManagerShellCommand.runStartAct
ivity(ActivityManagerShellCommand.java:412)
[MJSONWP] at com.android.server.am.ActivityManagerShellCommand.onCommand(A
ctivityManagerShellCommand.java:141)
[MJSONWP] at android.os.ShellCommand.exec(ShellCommand.java:96)
[MJSONWP] at com.android.server.am.ActivityManagerService.onShellCommand(A
ctivityManagerService.java:15014)
[MJSONWP] at android.os.Binder.shellCommand(Binder.java:594)
[MJSONWP] at android.os.Binder.onTransact(Binder.java:492)
[MJSONWP] at android.app.IActivityManager$Stub.onTransact(IActivityManager
.java:4243)
[MJSONWP] at com.android.server.am.ActivityManagerService.onTransact(Activ
ityManagerService.java:2919)
[MJSONWP] at android.os.Binder.execTransact(Binder.java:697)'; Code: '4294
967295'
[MJSONWP] at ADB.callee$0$0$ (C:\Users\usl014\AppData\Roaming\npm\node_modul
es\appium\node_modules\appium-adb\lib\tools\apk-utils.js:125:11)
[MJSONWP] at tryCatch (C:\Users\usl014\AppData\Roaming\npm\node_modules\appi
um\node_modules\babel-runtime\regenerator\runtime.js:67:40)
[MJSONWP] at GeneratorFunctionPrototype.invoke [as _invoke] (C:\Users\usl014
\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\
runtime.js:315:22)
[MJSONWP] at GeneratorFunctionPrototype.prototype.(anonymous function) [as t
hrow] (C:\Users\usl014\AppData\Roaming\npm\node_modules\appium\node_modules\babe
l-runtime\regenerator\runtime.js:100:21)
[MJSONWP] at GeneratorFunctionPrototype.invoke (C:\Users\usl014\AppData\Roam
ing\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:13
6:37)

我的测试代码:

*** Settings ***
Documentation Suite description
Library AppiumLibrary

*** Variables ***
${REMOTE_URL} http://localhost:4723/wd/hub
${PLATFORM_NAME} Android
${PLATFORM_VERSION} 8.1
${DEVICE_NAME} Pixel 2 XL API 27
${APP} C:/Users/usl014/PycharmProjects/robotframeworkdemo/tests/demoapp/app-debug.apk

*** Test Cases ***
Test title
Open Application ${REMOTE_URL} platformName=Android platformVersion=${PLATFORM_VERSION} autoGrantPermissions=true deviceName=${DEVICE_NAME} app=${APP} automationName=appium appActivity=gr.cosmote.testcosmoteidsdk.activities.HomeActivity
Capture Page Screenshot
Close Application

最后,应用程序的 list 如下:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="gr.cosmote.testcosmoteidsdk">

<uses-permission android:name="android.permission.INTERNET" />

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".activities.HomeActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".activities.LoginActivity"
android:exported="true" />
<activity android:name=".activities.RegisterActivity"
android:exported="true" />
<activity android:name=".activities.GreetingActivity"
android:exported="true" />
</application>

</manifest>

在 list 中,我添加了 android:exported="true",这是我找到的建议,但对我不起作用。任何帮助将不胜感激!

提前致谢。

最佳答案

您遇到的问题与 Robotframework 或 Appium 无关。这是因为您的 Activity 无法启动。我建议摆脱 intent-filter,看看是否有帮助。

否则,暂时跳过 Appium,在终端中使用 adb shell 来确保解决问题:一旦 am start -n yourpackagename/.activityname 将毫无问题地运行应用程序,您就可以返回 Appium

关于android - 机器人框架 - Appium 库 : Security Exception while starting the application,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51261390/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com