赞
踩
最近在用appnium连接真机打开某个APP不管怎么改的一直报这个错,最后无意间查看了很多文章,偶然发现这是由于APP的活动名有多个,使用dumpsys activity | grep "ResumedActivity"命令得到的APP的包名不是真正的包名,导致提示相关权限问题的错误。
Failed to create session. An unknown server-side error occurred while processing the command. Original error: Cannot start the 'com.max.xiaoheihe' application. Visit https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/android/activity-startup.md for troubleshooting. Original error: Error executing adbExec. Original error: 'Command 'D:\Android\android-sdk-windows\platform-tools\adb.exe -P 5037 -s 89879572 shell am start -n com.max.xiaoheihe/.MainActivity -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000' exited with code 255'; Command output: Exception occurred while executing 'start': java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.max.xiaoheihe/.MainActivity } from null (pid=18634, uid=2000) not exported from uid 10184 at com.android.server.wm.ActivityTaskSupervisor.checkStartAnyActivityPermission(ActivityTaskSupervisor.java:1059) at com.android.server.wm.ActivityStarter.executeRequest(ActivityStarter.java:983) at com.android.server.wm.ActivityStarter.execute(ActivityStarter.java:672) at com.android.server.wm.ActivityTaskManagerService.startActivityAsUser(ActivityTaskManagerService.java:1243) at com.android.server.wm.ActivityTaskManagerService.startActivityAsUser(ActivityTaskManagerService.java:1215) at com.android.server.am.ActivityManagerService.startActivityAsUserWithFeature(ActivityManagerService.java:2958) at com.android.server.am.ActivityManagerShellCommand.runStartActivity(ActivityManagerShellCommand.java:572) at com.android.server.am.ActivityManagerShellCommand.onCommand(ActivityManagerShellCommand.java:201) at com.android.modules.utils.BasicShellCommandHandler.exec(BasicShellCommandHandler.java:97) at android.os.ShellCommand.exec(ShellCommand.java:38) at com.android.server.am.ActivityManagerService.onShellCommand(ActivityManagerService.java:8668) at android.os.Binder.shellCommand(Binder.java:950)
我是打开的小黑盒这个APP,我才开始使用的包名和活动名分别是com.max.xiaoheihe和.MainActivity,始终就报错,一直连接不上,就算我把活动名字补全com.max.xiaoheihe.MainActivity,也始终报这个错误。
使用命令dumpsys package com.max.xiaoheihe获得这个APP所有的活动名,然后找关键信息android.intent.action.MAIN:
64b6316 com.max.xiaoheihe/.SplashActivity filter f4e1497
Action: "android.intent.action.MAIN"
Category: "android.intent.category.LAUNCHER"
比如这里查看到android.intent.action.MAIN:有这个关键信息,并且下发是自己APP的包名的话通常后面这个就是这个APP的真正活动包名也就是入口,比如我这里就是.SplashActivity
参看github的一个issue,但是这个方法没有帮助到我;不过给了一些方向:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。