1. 程式人生 > 其它 >真機使用adb命令開啟包名報錯 java.lang.SecurityException: Permission Denial: starting Intent 【已解決】

真機使用adb命令開啟包名報錯 java.lang.SecurityException: Permission Denial: starting Intent 【已解決】

使用adb命令安裝包名的時候報錯了

我是直接用adb shelldumpsys window | findstr mCurrentFocus 獲取的

獲取到了這一段: uni.UNIDD11F28/io.dcloud.PandoraEntryActivity

但是我用這一段準備開啟app的時候報錯了

C:\Users\admin>adb shell am start uni.UNIDD11F28/io.dcloud.PandoraEntryActivity
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=uni.UNIDD11F28/io.dcloud.PandoraEntryActivity }
Security exception: Permission Denial: starting Intent { act
=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=uni.UNIDD11F28/io.dcloud.PandoraEntryActivity } from null (pid=26830, uid=2000) not exported from uid 10233 java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000
cmp=uni.UNIDD11F28/io.dcloud.PandoraEntryActivity } from null (pid=26830, uid=2000) not exported from uid 10233 at com.android.server.wm.ActivityStackSupervisor.checkStartAnyActivityPermission(ActivityStackSupervisor.java:1089) at com.android.server.wm.ActivityStarter.startActivity(ActivityStarter.java:
789) at com.android.server.wm.ActivityStarter.startActivity(ActivityStarter.java:588) at com.android.server.wm.ActivityStarter.startActivityMayWait(ActivityStarter.java:1390) at com.android.server.wm.ActivityStarter.execute(ActivityStarter.java:519) at com.android.server.wm.ActivityTaskManagerService.startActivityAsUser(ActivityTaskManagerService.java:1091) at com.android.server.wm.ActivityTaskManagerService.startActivityAsUser(ActivityTaskManagerService.java:1065) at com.android.server.am.ActivityManagerService.startActivityAsUser(ActivityManagerService.java:3569) at com.android.server.am.ActivityManagerShellCommand.runStartActivity(ActivityManagerShellCommand.java:518) at com.android.server.am.ActivityManagerShellCommand.onCommand(ActivityManagerShellCommand.java:172) at android.os.ShellCommand.exec(ShellCommand.java:104) at com.android.server.am.ActivityManagerService.onShellCommand(ActivityManagerService.java:10093) at android.os.Binder.shellCommand(Binder.java:881) at android.os.Binder.onTransact(Binder.java:765) at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:4727) at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2799) at android.os.Binder.execTransactInternal(Binder.java:1021) at android.os.Binder.execTransact(Binder.java:994)

然後再網上查閱資料發現,我們獲取到的活動入口可能不是真正的入口

解決問題方案如下:

1.我們通過拿到包名去獲取包的詳細資訊

adb shell
dumpsys package uni.UNIDD11F28

我標記出來的為真正的包名

2.重新開啟app

adb shell am start uni.UNIDD11F28/io.dcloud.PandoraEntry

引用文章:https://blog.csdn.net/yangsummer2426/article/details/80929869

adb shelldumpsys window | findstr mCurrentFocus