繁体   English   中英

尝试在 MI MAX 2 android 设备上运行本机应用程序时应用程序安装调试任务期间出现安全异常

[英]SecurityException during app:installDebug Task while attempting to run react-native app on MI MAX 2 android device

运行npx react-native run-android正在 android 模拟器上npx react-native run-android ,也在我拥有的三星设备上运行。 但是当连接 MI MAX 2 设备时,我得到以下信息:

> Task :app:installDebug
Installing APK 'app-debug.apk' on 'MI MAX 2 - 7.1.1' for app:debug

> Task :app:installDebug FAILED

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.5/userguide/command_line_interface.html#sec:command_line_warnings
847 actionable tasks: 2 executed, 845 up-to-date
Unable to install /Users/[....]/android/app/build/outputs/apk/debug/app-debug.apk
com.android.ddmlib.InstallException: Unknown failure: Error: java.lang.SecurityException: You need the android.permission.INSTALL_GRANT_RUNTIME_PERMISSIONS permission to use the PackageManager.INSTALL_GRANT_RUNTIME_PERMISSIONS flag
        at com.android.ddmlib.internal.DeviceImpl.installRemotePackage(DeviceImpl.java:1224)
        at com.android.ddmlib.internal.DeviceImpl.installPackage(DeviceImpl.java:1050)
        at com.android.ddmlib.internal.DeviceImpl.installPackage(DeviceImpl.java:1026)
        at com.android.ddmlib.internal.DeviceImpl.installPackage(DeviceImpl.java:1015)
        at ... etc, etc, etc

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:installDebug'.
> java.util.concurrent.ExecutionException: com.android.builder.testing.api.DeviceException: com.android.ddmlib.InstallException: Unknown failure: Error: java.lang.SecurityException: You need the android.permission.INSTALL_GRANT_RUNTIME_PERMISSIONS permission to use the PackageManager.INSTALL_GRANT_RUNTIME_PERMISSIONS flag

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 30s

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=4105
Unable to install /Users/[....]/android/app/build/outputs/apk/debug/app-debug.apk

注意:我尝试将以下内容添加到我的AndroidManifest.xml但似乎没有任何区别:

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

有任何想法吗?

确保两者

  1. 开发者选项 -> USB 调试
  2. 开发者选项 -> USB 调试(安全设置)

已开启

我可以在启用Developer Options -> USB debugging (Security settings)选项的 MI POCO F2 Pro 上修复它。

从开发人员选项启用 USB 调试(安全设置)。 如果手机没有插入 SIM 卡,它会要求您插入 SIM 卡。

从我的 MI 设备中取出SIM card后,我遇到了这个问题。 从那以后,我再也无法接受 USB 调试(安全设置)了..

解决方案:我试过这个,我插入了我的 Sim 和开发人员选项 -> USB 调试(安全设置)和 USB 调试 - 都打开了但在我的设备中我仍然面临同样的问题然后我激活了:通过 USB 安装 - 打开在。 现在它工作正常,我猜我的 REDMI 设备有这个其他手机可能没有的附加选项。

此网页具有运行 Appium 的所有相关功能:http ://appium.io/docs/en/writing-running-appium/caps/index.html 在我的功能部分,我还为实际设备添加了 2 个新功能并导入了一个库说:

import io.appium.java_client.android.appmanagement.*;
    DesiredCapabilities cap= new DesiredCapabilities();
    cap.setCapability("autoGrantPermissions", "true");
    cap.setCapability("enforceAppInstall", "true");

在我的小米红米 Note 7 上,我不得不打开另一个名为“USB 调试(安全设置)”的选项。

它位于“USB 调试”选项下方不远处。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM