[英]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.xml
和android/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.