简体   繁体   English

Android React Native App 请求未在 android/app/src/main/AndroidManifest.xml 中定义的权限

[英]Android React Native App asking for permissions that are not defined within android/app/src/main/AndroidManifest.xml

I have a Android build of a react native app that I have uploaded to the Google Play console.我有一个已上传到 Google Play 控制台的 react 本机应用程序的 Android 版本。

I am having issues with the build of the app requesting more permissions than I have defined inside my apps android/app/src/main/AndroidManifest.xml我在构建应用程序时遇到问题,请求的权限超出了我在应用程序android/app/src/main/AndroidManifest.xml中定义的权限

I am having troubles with the QUERY_ALL_PACKAGES permission in particular which Google says my app is not compliant with.我在使用QUERY_ALL_PACKAGES权限时遇到问题,尤其是 Google 说我的应用程序不符合该权限。

The permissions defined inside my app android/app/src/main/AndroidManifest.xml are the below:在我的应用程序android/app/src/main/AndroidManifest.xml中定义的权限如下:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.android.vending.BILLING"/>

I then did a global search for QUERY_ALL_PACKAGES in my project and found it was defined in several places like:然后我在我的项目中对QUERY_ALL_PACKAGES进行了全局搜索,发现它是在几个地方定义的,例如:

android/app/build/intermediates/merged_manifests/release/AndroidManifest.xml



  <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
    <uses-permission android:name="android.permission.USE_BIOMETRIC" />
    <uses-permission android:name="android.permission.USE_FINGERPRINT" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> <!-- Required to access Google Play Licensing -->
    <uses-permission android:name="com.android.vending.CHECK_LICENSE" /> <!-- Required by older versions of Google Play services to create IID tokens -->
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
    <uses-permission android:name="com.google.android.finsky.permission.BIND_GET_INSTALL_REFERRER_SERVICE" />

and the android/app/build/intermediates/bundle_manifest/release/bundle-manifest/AndroidManifest.xmlandroid/app/build/intermediates/bundle_manifest/release/bundle-manifest/AndroidManifest.xml

<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
<uses-permission android:name="android.permission.USE_BIOMETRIC" />
<uses-permission android:name="android.permission.USE_FINGERPRINT" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> <!-- 
Required to access Google Play Licensing -->
<uses-permission android:name="com.android.vending.CHECK_LICENSE" /> <!-- Required by 
older versions of Google Play services to create IID tokens -->
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission 
android:name="com.google.android.finsky.permission.BIND_GET_INSTALL_REFERRER_SERVICE" 
/>

What are these files and why are they requiring permissions I have not set inside my android/app/src/main/AndroidManifest.xml这些文件是什么,为什么它们需要我没有在我的android/app/src/main/AndroidManifest.xml中设置的权限

How would I go about removing a permission requested by these files like the android.permission.QUERY_ALL_PACKAGES我将如何删除这些文件请求的权限,例如android.permission.QUERY_ALL_PACKAGES

Any help or guidance would be greatly appreciated.任何帮助或指导将不胜感激。

Best, Matt最好的,马特

By default, some permissions are added to your Android APK.默认情况下,一些权限会添加到您的 Android APK。 To remove them, just add few lines in android/app/src/main/AndroidManifest.xml file要删除它们,只需在 android/app/src/main/AndroidManifest.xml 文件中添加几行

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.myappid"
+   xmlns:tools="http://schemas.android.com/tools"
    >

+   <uses-permission tools:node="remove" android:name="android.permission.QUERY_ALL_PACKAGES" />
.....
</manifest>

Also you can find the reference here in the official documentation : https://reactnative.dev/docs/0.62/removing-default-permissions您也可以在官方文档中找到参考: https ://reactnative.dev/docs/0.62/removing-default-permissions

I would recommend in addition to the other answer provided find out which library in your project is trying to add that permission and remove it.除了提供的其他答案之外,我还建议您找出项目中的哪个库正在尝试添加该权限并将其删除。 That permissions should be rarely used as it's able to grab the package names of every app the user has installed.该权限应该很少使用,因为它能够获取用户安装的每个应用程序的包名称。 It's not a recommended practise.这不是推荐的做法。

暂无
暂无

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

相关问题 Flutter 错误:任务“:app:generateDebugBuildConfig”执行失败。 (/android/app/src/main/AndroidManifest.xml 中的问题) - Flutter error : Execution failed for task ':app:generateDebugBuildConfig'. (problem in /android/app/src/main/AndroidManifest.xml ) Android 应用程序 - AndroidManifest.xml 不起作用 - Android App - AndroidManifest.xml does not work 如何获取 android 应用程序的 AndroidManifest.xml - How to get AndroidManifest.xml of an android app 在Android Studio的AndroidManifest.xml中添加权限? - Adding Permissions in AndroidManifest.xml in Android Studio? AndroidManifest.xml 中的最大 Android 权限 - Maximum Android permissions in AndroidManifest.xml 使用 React Native 构建的 Android 应用程序和 Expo 仍在请求应用程序权限 - Android app built with React Native and Expo still asking for app permissions 如何保护Android应用程序的AndroidManifest.xml文件? - How to protect Android app's AndroidManifest.xml file? 错误:无法解析 C 中的 XML:\Users\aNTA\AndroidStudioProjects\break\app\src\main\AndroidManifest.Z0F635D0E0F3874FFF8B581C132 - ERROR: Failed to parse XML in C:\Users\aNTA\AndroidStudioProjects\breaking\app\src\main\AndroidManifest.xml 没有`<meta-data android:name="flutterEmbedding" android:value="2" /> ` 在 "..\src\main\AndroidManifest.xml" - No `<meta-data android:name="flutterEmbedding" android:value="2"/>` in "..\src\main\AndroidManifest.xml" 错误:无法从app / src / main / AndroidManifest.xml中读取packageName - Error:Cannot read packageName from app/src/main/AndroidManifest.xml
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM