【发布时间】:2017-01-09 18:42:29
【问题描述】:
我刚刚在我的构建中打开了 ProGuard,现在我得到了一个
java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.chimera.GmsModuleInitializer" on path: DexPathList[[zip file "/system/app/PlayGames.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
文档说我需要将 Proguard 与 Play Services 一起使用的所有内容都应该包含在 Android Gradle 插件中:
注意:ProGuard 指令包含在 Play 服务客户端中 库以保留所需的类。 Android 插件 Gradle 自动在 AAR 中附加 ProGuard 配置文件 (Android ARchive) 打包并将该包附加到您的 ProGuard 配置。在项目创建过程中,Android Studio 会自动 创建 ProGuard 配置文件和 build.gradle 属性 供 ProGuard 使用。要将 ProGuard 与 Android Studio 一起使用,您必须启用 build.gradle buildTypes 中的 ProGuard 设置。更多 信息,请参阅 ProGuard 指南。
这是我的应用模块 build.gradle 文件的重要部分:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
...
}
...
buildTypes {
...{
applicationIdSuffix ".debug"
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
}
dependencies {
...
//google play services
compile 'com.google.android.gms:play-services-gcm:8.4.0'
compile 'com.google.android.gms:play-services-analytics:8.4.0'
compile 'com.google.android.gms:play-services-location:8.4.0'
}
这是我的顶级 build.gradle 文件:
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
}
}
我错过了什么?
【问题讨论】:
标签: google-play-services proguard