React Native 此权限(android.permission.QUERY_ALL_PACKAGES)已自动添加到清单

px9o7tmv  于 2022-11-17  发布在  React
关注(0)|答案(6)|浏览(155)

我有一个React原生应用程序,它工作得很好,直到升级包实际上升级包后,此权限添加(android.permission.QUERY_ALL_PACKAGES)到清单.请帮助我
这是第一个package.json

{
  "name": "mazeapp",
  "version": "2.0.0",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint ."
  },
  "dependencies": {
    "@gregfrench/react-native-wheel-picker": "^1.2.15",
    "@miblanchard/react-native-slider": "^2.0.1",
    "@react-native-community/async-storage": "1.12.1",
    "@react-native-community/checkbox": "0.3.0",
    "@react-native-community/netinfo": "4.6.0",
    "@react-native-community/toolbar-android": "0.1.0-rc.2",
    "@react-native-firebase/app": "6.7.1",
    "@react-native-firebase/messaging": "6.7.1",
    "@react-native-picker/picker": "^1.9.10",
    "axios": "^0.19.0",
    "lottie-react-native": "3.5.0",
    "moment-jalaali": "^0.9.2",
    "react": "16.9.0",
    "react-dom": "16.9.0",
    "react-native": "0.61.5",
    "react-native-app-intro-slider": "4.0.4",
    "react-native-awesome-alerts": "1.4.2",
    "react-native-background-actions": "^2.6.4",
    "react-native-background-timer": "2.4.1",
    "react-native-check-box": "^2.1.7",
    "react-native-confirmation-code-field": "^4.1.0",
    "react-native-date-picker": "3.2.5",
    "react-native-device-info": "5.6.5",
    "react-native-easy-toast": "^1.2.0",
    "react-native-emoji": "1.8.0",
    "react-native-exit-app": "^1.1.0",
    "react-native-file-picker": "0.0.19",
    "react-native-fs": "^2.16.6",
    "react-native-gesture-handler": "1.5.6",
    "react-native-i18n": "^2.0.15",
    "react-native-image-crop-picker": "^0.28.0",
    "react-native-image-picker": "2.3.4",
    "react-native-inappbrowser-reborn": "^3.5.1",
    "react-native-item-select": "0.3.0",
    "react-native-modal": "11.5.6",
    "react-native-modalbox": "2.0.2",
    "react-native-motion": "1.0.5",
    "react-native-otp-verify": "^1.0.3",
    "react-native-persian-calendar-picker": "^3.1.1",
    "react-native-popup-dialog": "0.18.3",
    "react-native-progress": "4.1.2",
    "react-native-push-notification": "^7.3.1",
    "react-native-rate": "^1.2.4",
    "react-native-ratings": "^7.4.0",
    "react-native-reanimated": "~1.4.0",
    "react-native-root-toast": "3.2.1",
    "react-native-safe-area-context": "0.6.0",
    "react-native-screens": "2.0.0-alpha.12",
    "react-native-sectioned-multi-select": "0.8.1",
    "react-native-select-contact": "^1.5.0",
    "react-native-simple-modal": "^9.0.1",
    "react-native-simple-radio-button": "^2.7.4",
    "react-native-snap-carousel": "^3.9.1",
    "react-native-sound": "0.11.0",
    "react-native-sqlite-storage": "^5.0.0",
    "react-native-stars": "^1.2.2",
    "react-native-step-indicator": "^1.0.3",
    "react-native-svg": "9.13.3",
    "react-native-svg-charts": "5.4.0",
    "react-native-swiper": "^1.6.0",
    "react-native-table-component": "^1.2.1",
    "react-native-textinput-effects": "^0.5.1",
    "react-native-typing-animation": "^0.1.7",
    "react-native-uuid-generator": "^6.1.1",
    "react-native-vector-icons": "6.7.0",
    "react-native-view-more-text": "^2.1.0",
    "react-native-web": "^0.11.7",
    "react-native-webview": "^11.4.1",
    "react-navigation": "4.4.3",
    "react-navigation-stack": "^1.10.3",
    "react-navigation-tabs": "2.10.1",
    "react-number-format": "4.4.1",
    "react-redux": "7.2.2",
    "redux": "^4.0.4",
    "redux-thunk": "^2.3.0",
    "rn-fetch-blob": "^0.12.0",
    "socket.io-client": "^2.4.0",
    "styled-components": "5.2.1",
    "victory-native": "^33.0.1"
  },
  "devDependencies": {
    "@babel/core": "7.12.3",
    "@babel/runtime": "7.12.1",
    "@react-native-community/eslint-config": "^0.0.7",
    "babel-jest": "25.5.1",
    "eslint": "^6.8.0",
    "jest": "25.5.4",
    "jetifier": "1.6.6",
    "metro-react-native-babel-preset": "^0.58.0",
    "react-native-bundle-visualizer": "2.2.1",
    "react-test-renderer": "16.9.0"
  },
  "jest": {
    "preset": "react-native"
  }
}

这是secound文件package.json

{
  "name": "mazeapp",
  "version": "2.1.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint ."
  },
  "dependencies": {
    "@miblanchard/react-native-slider": "^2.0.1",
    "@react-native-community/async-storage": "1.12.1",
    "@react-native-community/checkbox": "0.3.0",
    "@react-native-community/netinfo": "4.6.0",
    "@react-native-community/toolbar-android": "^0.2.1",
    "@react-native-firebase/analytics": "^14.0.0",
    "@react-native-firebase/app": "^14.0.0",
    "@react-native-firebase/messaging": "^14.0.0",
    "axios": "^0.19.0",
    "lottie-react-native": "3.5.0",
    "moment-jalaali": "^0.9.2",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-native": "^0.66.4",
    "react-native-app-intro-slider": "4.0.4",
    "react-native-awesome-alerts": "1.4.2",
    "react-native-background-actions": "^2.6.4",
    "react-native-background-timer": "2.4.1",
    "react-native-check-box": "^2.1.7",
    "react-native-confirmation-code-field": "^7.2.0",
    "react-native-device-info": "5.6.5",
    "react-native-emoji": "1.8.0",
    "react-native-exit-app": "^1.1.0",
    "react-native-file-picker": "0.0.19",
    "react-native-fs": "^2.16.6",
    "react-native-gesture-handler": "1.5.6",
    "react-native-image-crop-picker": "^0.28.0",
    "react-native-image-picker": "2.3.4",
    "react-native-inappbrowser-reborn": "^3.5.1",
    "react-native-item-select": "0.3.0",
    "react-native-modal": "11.5.6",
    "react-native-modalbox": "2.0.2",
    "react-native-motion": "1.0.5",
    "react-native-otp-verify": "^1.0.3",
    "react-native-persian-calendar-picker": "^3.1.1",
    "react-native-progress": "4.1.2",
    "react-native-push-notification": "^7.3.1",
    "react-native-rate": "^1.2.4",
    "react-native-ratings": "^7.4.0",
    "react-native-reanimated": "~1.4.0",
    "react-native-root-toast": "^3.3.0",
    "react-native-safe-area-context": "^3.3.2",
    "react-native-screens": "2.0.0-alpha.12",
    "react-native-select-contact": "^1.5.0",
    "react-native-simple-modal": "^9.0.1",
    "react-native-simple-radio-button": "^2.7.4",
    "react-native-snap-carousel": "^3.9.1",
    "react-native-sound": "0.11.0",
    "react-native-sqlite-storage": "^5.0.0",
    "react-native-stars": "^1.2.2",
    "react-native-step-indicator": "^1.0.3",
    "react-native-svg": "^9.13.3",
    "react-native-svg-charts": "5.4.0",
    "react-native-swiper": "^1.6.0",
    "react-native-textinput-effects": "^0.5.1",
    "react-native-typing-animation": "^0.1.7",
    "react-native-uuid-generator": "^6.1.1",
    "react-native-vector-icons": "^9.0.0",
    "react-native-view-more-text": "^2.1.0",
    "react-native-web": "^0.11.7",
    "react-native-webview": "^11.4.1",
    "react-navigation": "4.4.3",
    "react-navigation-stack": "^1.10.3",
    "react-navigation-tabs": "^2.10.1",
    "react-number-format": "4.4.1",
    "react-redux": "7.2.2",
    "redux": "^4.0.4",
    "redux-thunk": "^2.3.0",
    "rn-fetch-blob": "^0.12.0",
    "socket.io-client": "^2.4.0",
    "victory-native": "^33.0.1"
  },
  "devDependencies": {
    "@babel/core": "7.16.5",
    "@babel/runtime": "7.16.5",
    "@react-native-community/eslint-config": "2.0.0",
    "babel-jest": "26.6.3",
    "eslint": "7.14.0",
    "jest": "26.6.3",
    "jetifier": "1.6.6",
    "metro-react-native-babel-preset": "0.66.2",
    "react-native-bundle-visualizer": "2.2.1",
    "react-test-renderer": "17.0.2"
  },
  "jest": {
    "preset": "react-native"
  }
}

build.gradle
//顶级生成文件,您可以在其中添加所有子项目/模块通用配置选项

buildscript {
    ext {
        // googlePlayServicesVersion = "4.3.3" // default: "+"
        // firebaseMessagingVersion = "+" // default: "+"
        buildToolsVersion = "30.0.2"
        minSdkVersion = 21
        compileSdkVersion = 30
        targetSdkVersion = 30
        supportLibVersion = "28.0.0"
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath("com.android.tools.build:gradle:4.2.2")
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        classpath 'com.google.gms:google-services:4.3.3'
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.8.1'
    }
}

allprojects {
    repositories {
        mavenCentral()
        mavenLocal()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url("$rootDir/../node_modules/react-native/android")
        }
        maven {
            // Android JSC is installed from npm
            url("$rootDir/../node_modules/jsc-android/dist")
        }
        google()
        maven { url 'https://jitpack.io' }
  
      }
}
6jjcrrmo

6jjcrrmo1#

对于那些有类似问题或必须向Play商店解释为什么有这个权限的人,这是由react-native-inappbrowser-renbal包添加的,这里有一个PR来修复这个问题:
https://github.com/proyecto26/react-native-inappbrowser/pull/335
看起来在写这篇文章的时候,它并没有在NPM目录中。但是你应该试着更新这个包,看看它是否消失了。
确定哪个依赖项注入权限的一种方法是在项目的根目录下运行以下命令(在基于Unix的操作系统上):

grep -r QUERY_ALL_PACKAGES *

这将告诉你的文件,有该文本,这将指出你在正确的方向。

dbf7pr2w

dbf7pr2w2#

正是由于目标SDK更新到30,一些特性(例如:语音识别,TTS)在android 11设备中工作,只有在我们的AndroidManifest.xml中添加以下代码后

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

还有<activity>中的android:exported="true"
这里提到的是行为变化:面向Android 11的应用
您可能必须在manifest header标记中以独占方式声明tools名称空间,这样才能使其正常工作。xmlns:tools="http://schemas.android.com/tools",这样标头将如下所示

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.example.app">
eoigrqb6

eoigrqb63#

您可以使用确认该软件包是否包含在您的apk中。
apkTook
1.按照网站上的说明进行安装
1.建立你的apk
1.运行apktool decode /path/to/your/app-release.apk
1.现在应该有一个巨大的合并清单文件包含您的apk的所有权限。
一旦你确认了许可包含在你的apk中。
然后可以使用@imekinox的answer来检测哪个依赖项包含该权限。
然后,您可以选择禁用该权限,使其不显示在最终APk文件中
通过在清单中包含以下更改。

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

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

请注意,清单文件的顶部需要xmlns:tools="http://schemas.android.com/tools"
问题很可能是https://github.com/proyecto26/react-native-inappbrowser/pull/335,以这种方式禁用权限可能会破坏此软件包或其他软件包。
真实的的修复方法是删除或更新包含此权限的任何依赖项。

368yc8dk

368yc8dk4#

对于那些遵循“Thanhal”的回答的人:
检查您的AndroidManifest.xml文件并添加

xmlns:tools="http://schemas.android.com/tools"

如果清单标记不存在,则返回到清单标记。
例如:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
  package="your-app-package">
jjhzyzn0

jjhzyzn05#

@imekinox有正确的解决方案,但是,在我进入他链接的Github页面后,react-native-inappbrowser的修复被合并,但还没有发布新的版本。
我找到了另一个NPM版本,其中包括:https://www.npmjs.com/package/@jinshin1013/react-native-inappbrowser-reborn
卸载旧版本并安装此版本,这样应该可以修复它。

qkf9rpyu

qkf9rpyu6#

如果您使用QUERY_ALL_PACKAGES权限,您的应用很可能会被Play商店拒绝。
如以下链接中所述,“在极少数情况下,如果元素无法提供足够的包可见性,您可以使用QUERY_ALL_PACKAGES权限。如果您在Google Play上发布应用,则应用使用此权限需要经过批准。”
https://developer.android.com/training/package-visibility
如下所述,将查询添加到AndroidManifest.xml文件。

<queries>
    <intent>
        <action android:name="android.support.customtabs.action.CustomTabsService" />
    </intent>
    <intent>
        <action android:name="android.intent.action.VIEW" />

        <category android:name="android.intent.category.BROWSABLE" />

        <data android:scheme="http" />
    </intent>
    <intent>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="https" />
    </intent>
    <intent>
        <action android:name="android.media.action.IMAGE_CAPTURE" />
    </intent>
    <intent>
        <action android:name="android.intent.action.GET_CONTENT" />
    </intent>
</queries>

相关问题