机械手框架-Appium库:启动应用程序时的安全异常

时间:2018-07-10 09:13:32

标签: android appium robotframework

我想测试一个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

最后,该应用程序的清单如下:

<?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>

在清单中,我添加了android:exported =“ true”,这是我发现的建议,但对我不起作用。任何帮助将不胜感激!

谢谢。

1 个答案:

答案 0 :(得分:1)

您面临的问题与Robotframework或Appium没有关系。这是因为您的活动无法启动。 我建议摆脱意图过滤器,看看是否有帮助。

否则,请暂时跳过Appium,在终端中使用adb shell来确保解决此问题: am start -n yourpackagename/.activityname将在没有任何问题的情况下运行应用程序,您可以回到Appium