Appium [求大神帮忙] appium1.6.5+python3.4+android8.0.0 测试微信小程序时报错 Original error: 'Command 'D\:\\android-sdk\\platform-tools\\adb.exe -P 5037 -s 8c5b7053 shell appops set io.appium.settings android\:mock_location allow' exited with code 4294967295'; Stderr: 'Security exception: uid 2000 does not have android.permission.UPDATE_APP_OPS_STATS.

小小测试 · 2018年09月15日 · 最后由 小小测试 回复于 2018年09月17日 · 4018 次阅读

各位大神,麻烦帮忙看看这个错误时什么原因,改怎么解决;求大神帮忙
appium1.6.5+python3.4+android8.0.0 测试微信小程序时报以下错误(日志中从空格开始时报错地方),但是使用连接 android4.2.2 模拟器不会报错
目前自己试过更新 sdk 到 android8.1.0;但仍不能解决问题
代码如下:运行到箭头指向的 driver 这句时就报错

appium 报错日志:
ADB] Device API level: 26
[ADB] Getting connected devices...
[ADB] 2 device(s) connected
[ADB] Running 'D:\android-sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","8c5b7053","shell","appops","set","io.appium.settings","android:mock_location","allow"]
[ADB] Running 'D:\android-sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","8c5b7053","shell","appops","set","io.appium.settings","android:mock_location","allow"]
[AndroidDriver] Shutting down Android driver
[AndroidDriver] Called deleteSession but bootstrap wasn't active
[Logcat] Stopping logcat capture
[ADB] Getting connected devices...
[ADB] 2 device(s) connected
[ADB] Running 'D:\android-sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","8c5b7053","shell","am","force-stop","io.appium.unlock"]
[AndroidDriver] Not cleaning generated files. Add clearSystemFiles capability if wanted.

[MJSONWP] Encountered internal error running command: Error: Error executing adbExec. Original error: 'Command 'D:\android-sdk\platform-tools\adb.exe -P 5037 -s 8c5b7053 shell appops set io.appium.settings android:mock_location allow' exited with code 4294967295'; Stderr: 'Security exception: uid 2000 does not have android.permission.UPDATE_APP_OPS_STATS.
java.lang.SecurityException: uid 2000 does not have android.permission.UPDATE_APP_OPS_STATS.
at android.app.ContextImpl.enforce(ContextImpl.java:1745)
at android.app.ContextImpl.enforcePermission(ContextImpl.java:1758)
at com.android.server.AppOpsService.setMode(AppOpsService.java:715)
at com.android.server.AppOpsService.onShellCommand(AppOpsService.java:2077)
at com.android.server.AppOpsService$Shell.onCommand(AppOpsService.java:1851)
at android.os.ShellCommand.exec(ShellCommand.java:96)
at com.android.server.AppOpsService.onShellCommand(AppOpsService.java:2025)
at android.os.Binder.shellCommand(Binder.java:576)
at android.os.Binder.onTransact(Binder.java:476)
at com.android.internal.app.IAppOpsService$Stub.onTransact(IAppOpsService.java:351)
at android.os.Binder.execTransact(Binder.java:679)'; Code: '4294967295'
at ADB.execFunc$ (C:\Users\Yang\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\appium-adb\lib\tools\system-calls.js:228:13)
at tryCatch (C:\Users\Yang\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40)
at GeneratorFunctionPrototype.invoke [as _invoke]

共收到 5 条回复 时间 点赞

求大神现身

这标题真长

SinDynasty 回复

知道什么问题吗?

4楼 已删除

建议你升级下 appium 的版本,我看最新版本在设置 mock_location 的时候对异常是有捕获的

helpers.setMockLocationApp = async function (adb, app) {
  try {
    if (await adb.getApiLevel() < 23) {
      await adb.shell(['settings', 'put', 'secure', 'mock_location', '1']);
    } else {
      await adb.shell(['appops', 'set', app, 'android:mock_location', 'allow']);
    }
  } catch (err) {
    logger.warn(`Unable to set mock location for app '${app}': ${err.message}`);
  }
};

代码地址:android-helpers.js

Viking Den 回复

好的,我先升级试试。谢谢

需要 登录 後方可回應,如果你還沒有帳號按這裡 注册