为什么玩-服务定位所需要的android.permission.WRITE_EXTERNAL_STORAGE和android.permission.READ_EXTERNAL_STORAGE权限? [英] Why does play-services-location need the android.permission.WRITE_EXTERNAL_STORAGE and android.permission.READ_EXTERNAL_STORAGE permissions?
问题描述
我只有在AndroidManifest.xml中是:
All I have in AndroidManifest.xml is:
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
上传APK给开发者控制台后,它增加了两个新的权限:
After uploading the APK to the developer console, it adds two new permissions:
我的build.gradle:
My build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "net.perspiratron.ifpaprofile"
minSdkVersion 15
targetSdkVersion 22
versionCode 3
versionName "1.2"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
// wearApp project(':wear')
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.google.android.gms:play-services-analytics:7.5.0'
compile 'com.google.android.gms:play-services-location:7.5.0'
compile 'com.jjoe64:graphview:4.0.0'
}
这是我加入的唯一的事情就是播放服务定位。为什么这个库需要它吗?
The only thing that I added was play-services-location. Why does this library need it?
推荐答案
简短的回答:我不相信播放服务,位置确实需要这些权限。它也不似乎需要 android.permission.ACCESS_NETWORK_STATE
或 android.permission.INTERNET对
,它也正在增加。
Short answer: I don't believe play-services-location does need those permissions. Neither does it seem to need android.permission.ACCESS_NETWORK_STATE
or android.permission.INTERNET
, which are also being added.
更长的答案: 看着我的清单合并的日志,似乎所有这四个权限都被包括在播放服务,地图的请求,这-location是连接在它自己的协议。我的应用程序没有使用-maps,只是-location。
Longer answer: Looking at my manifest merger log, it appears that all four of these permissions are being included at the request of play-services-maps, which -location is linking in of its own accord. My app isn't using -maps, just -location.
另外,我发现,这种现象只是出现在播放服务定位7.5.0版本;之前的版本不包括-maps,并且不添加这些权限。
Further, I've found that this behavior just appeared in version 7.5.0 of play-services-location; prior versions didn't include -maps, and don't add those permissions.
其实,我怀疑这方面发挥-服务,地图是偶然的,并会在大湄公河次区域的未来版本中删除。
I actually suspect that this connection to play-services-maps is accidental, and will be removed in a future release of GMS.
由马克·墨菲(CommonsWare)给出的链接之后,你可以通过添加如下行到你的清单中,从你的应用程序中删除这些权限:
Following up on the link given by Mark Murphy (CommonsWare), you can remove these permissions from your app by adding the following lines to your manifest:
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" tools:node="remove" />
<uses-permission android:name="android.permission.INTERNET" tools:node="remove" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" tools:node="remove" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" tools:node="remove" />
请注意,您还需要的xmlns:工具=http://schemas.android.com/tools
在打开的&LT ;清单...&GT;
元素,使这些工作。和平常的警告适用于:我的应用程序精细的工作采取这一步骤之后,但情况因人而异
Note that you'll also need xmlns:tools="http://schemas.android.com/tools"
in your opening <manifest ... >
element to make these work. And the usual caveats apply: my app worked fine after taking this step, but YMMV.
更新2015年9月10号:马克·墨菲(@commonsware)做的一个优秀的书面记录就在他的博客这个问题,包括我的解决方案的风险进行了讨论。
Update 10 Sep 2015: Mark Murphy (@commonsware) has done an excellent writeup on this issue on his blog, including a discussion of the risks of my solution.
这篇关于为什么玩-服务定位所需要的android.permission.WRITE_EXTERNAL_STORAGE和android.permission.READ_EXTERNAL_STORAGE权限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!