Google Play 服务添加不需要的权限
Google Play Services adding unwanted permissions
阅读以下问题后:
我意识到我需要更改 build.gradle
.
中的已编译项目
目前我有 compile 'com.google.android.gms:play-services:7.5.0'
但这增加了很多不必要的权限,如位置、读取和写入 SD 卡的权限、完全网络访问权限、查看网络连接等。我只使用 Google Play 服务来获取我游戏中的排行榜和成就。所以我认为我的应用程序不需要任何这些权限。
那么我应该编译什么呢?我必须列出具体的服务,但我无法找到可供我挑选的服务列表。
它会是这样的:
compile 'com.google.android.gms:play-services-achievements7.5.0'
compile 'com.google.android.gms:play-services-leaderboards7.5.0'
对于仅在 Google Play 上使用这些服务的游戏,我希望获得尽可能少的权限。
我也在我的清单中声明了这些权限:
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
任何人都可以为我提供合适的编译服务吗?
更新
这是我的 build.gradle 文件:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "mjj.fling"
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
`dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.google.android.gms:play-services-games:7.5.0'
compile project(':BaseGameUtils')
apply plugin: 'com.google.gms.google-services'`
}
FAILURE: Build failed with an exception.
- 出了什么问题:
任务 ':app:processDebugResources' 执行失败。
Error: more than one library with package name 'com.google.android.gms'
You can temporarily disable this error with android.enforceUniquePackageName=false
However, this is temporary and will be enforced in 1.0
这是我在重建项目时遇到的错误。
- 尝试:
运行 使用 --stacktrace 选项获取堆栈跟踪。 运行 使用 --info 或 --debug 选项以获得更多日志输出。
构建失败
查看 https://developers.google.com/android/guides/setup 以获取有关 Google 如何设置 Play 服务的信息。尤其要查看标题为 Selectively compiling APIs into your executable
的小节。它向您展示了如何细分要编译的服务。您可能只想使用游戏之一:
com.google.android.gms:play-services-games:7.5.0
除了使用更少的权限外,它还会减少您的 APK 大小和方法数量,无论如何,这都是一件好事,而不是拉入整个 Play 服务库。
阅读以下问题后:
build.gradle
.
目前我有 compile 'com.google.android.gms:play-services:7.5.0'
但这增加了很多不必要的权限,如位置、读取和写入 SD 卡的权限、完全网络访问权限、查看网络连接等。我只使用 Google Play 服务来获取我游戏中的排行榜和成就。所以我认为我的应用程序不需要任何这些权限。
那么我应该编译什么呢?我必须列出具体的服务,但我无法找到可供我挑选的服务列表。
它会是这样的:
compile 'com.google.android.gms:play-services-achievements7.5.0'
compile 'com.google.android.gms:play-services-leaderboards7.5.0'
对于仅在 Google Play 上使用这些服务的游戏,我希望获得尽可能少的权限。
我也在我的清单中声明了这些权限:
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
任何人都可以为我提供合适的编译服务吗?
更新 这是我的 build.gradle 文件:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "mjj.fling"
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
`dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.google.android.gms:play-services-games:7.5.0'
compile project(':BaseGameUtils')
apply plugin: 'com.google.gms.google-services'`
}
FAILURE: Build failed with an exception.
- 出了什么问题:
任务 ':app:processDebugResources' 执行失败。
Error: more than one library with package name 'com.google.android.gms' You can temporarily disable this error with android.enforceUniquePackageName=false However, this is temporary and will be enforced in 1.0
这是我在重建项目时遇到的错误。
- 尝试: 运行 使用 --stacktrace 选项获取堆栈跟踪。 运行 使用 --info 或 --debug 选项以获得更多日志输出。
构建失败
查看 https://developers.google.com/android/guides/setup 以获取有关 Google 如何设置 Play 服务的信息。尤其要查看标题为 Selectively compiling APIs into your executable
的小节。它向您展示了如何细分要编译的服务。您可能只想使用游戏之一:
com.google.android.gms:play-services-games:7.5.0
除了使用更少的权限外,它还会减少您的 APK 大小和方法数量,无论如何,这都是一件好事,而不是拉入整个 Play 服务库。