我试图在谷歌play商店上发布我的应用程序,但他们说我不能,因为我使用位置,但我从未使用过它。
如果我制作了一个应用程序捆绑包,并用Android Studio打开它,我会在Manifest:上找到它
[...]
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
[...]
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
[...]
我该如何删除它?以及如何知道这在哪里使用?
我的包.json:
"dependencies": {
"@react-native-community/masked-view": "0.1.10",
"@react-native-community/netinfo": "5.9.2",
"@react-navigation/drawer": "^5.9.0",
"@react-navigation/material-bottom-tabs": "^5.2.16",
"@react-navigation/native": "^5.7.3",
"@react-navigation/stack": "^5.9.0",
"@types/react-native-snap-carousel": "^3.8.2",
"expo": "~38.0.8",
"expo-barcode-scanner": "~8.2.1",
"firebase": "7.9.0",
"react": "~16.11.0",
"react-dom": "~16.11.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-38.0.2.tar.gz",
"react-native-barcode-builder": "^2.0.0",
"react-native-circular-progress": "^1.3.6",
"react-native-gesture-handler": "~1.6.0",
"react-native-paper": "^4.1.0",
"react-native-reanimated": "~1.9.0",
"react-native-safe-area-context": "~3.0.7",
"react-native-screens": "~2.9.0",
"react-native-snap-carousel": "^3.9.1",
"react-native-svg": "^12.1.0"
},
"devDependencies": {
"@babel/core": "^7.8.6",
"@types/react": "~16.9.41",
"@types/react-native": "~0.62.13",
"typescript": "~3.9.5"
},
我遇到了同样的问题,Play Store从2021年3月29日起更改了位置权限策略。以下是我的发现:
1.对于有管理的博览会:
修改app.json添加"权限";并且只指定那些您想要的。这将覆盖世博会的默认权限集。如果您不需要任何权限,则可以使用空数组。
android: {
permissions: ["READ_CONTACTS", "WRITE_SETTINGS"]
...
参考编号:https://docs.expo.io/versions/latest/config/app/#permissions
请注意,Expo默认包含一些制造商权限。你可能想在中添加这些
"com.google.android.c2dm.permission.RECEIVE",
"com.anddoes.launcher.permission.UPDATE_COUNT",
"com.majeur.launcher.permission.UPDATE_BADGE",
"com.google.android.providers.gsf.permission.READ_GSERVICES",
"com.sonyericsson.home.permission.BROADCAST_BADGE",
"com.htc.launcher.permission.READ_SETTINGS",
"com.htc.launcher.permission.UPDATE_SHORTCUT",
"com.sec.android.provider.badge.permission.READ",
"com.sec.android.provider.badge.permission.WRITE"
2.对于裸展:
使用工具删除特定权限:node="删除">在您的AndroidManifest.xml 中
参考编号:https://docs.expo.io/versions/latest/sdk/permissions/#excluding-裸工作流中的android权限
3.展会地点
如果您安装了expo位置,它将自动请求ACCESS_COARSE_location和ACCESS_FINE_location(看起来也像ACCESS_BACKGROUND_location(。我曾经安装过expo-location,不得不手动将其从node_modules和package-lock.json中删除。
参考编号:https://docs.expo.io/versions/latest/sdk/permissions/#permissions-安卓
在文件 app.json中添加一个空的权限数组:
"android": {
"useNextNotificationsApi": true,
"package": "",
"permissions": [],
}
为了对权限进行细粒度控制,请使用expo-config插件。
- 使用AndroidRemovedPermissions.js在项目根目录中添加一个新文件:
const {
AndroidConfig,
createRunOncePlugin,
withAndroidManifest,
} = require('@expo/config-plugins');
const withAndroidRemovedPermissions = (config, permissionsToBeRemoved) => {
return withAndroidManifest(config, (config) => {
AndroidConfig.Permissions.removePermissions(config.modResults, permissions);
const usesPermissions = config.modResults.manifest['uses-permission'] || [];
permissions.forEach((permission) => {
permissionsToBeRemoved.push({
$: {
'tools:node': 'remove',
'android:name': permission,
},
});
});
config.modResults.manifest['uses-permission'] = usesPermissions;
config.modResults.manifest.$['xmlns:tools'] =
'http://schemas.android.com/tools';
return config;
});
};
module.exports = createRunOncePlugin(
withAndroidRemovedPermissions,
'withAndroidRemovedPermissions'
);
然后在你的app.json文件
{
"plugins": [
[
"./withAndroidRemovedPermissions",
[
"android.permission.WHATEVER_PERMISSION_YOU_NEED_1",
"android.permission.WHATEVER_PERMISSION_YO_NEED_2"
]
],
],
}