Google Play 服务库和 API 18(未找到 AppOpsManager)

Google Play Services Library and API 18 (AppOpsManager not found)

我使用 Google Play Services 并在 Gradle 中有选择地为 Admob 和 Analytics 编译,如下所示:

dependencies {
    compile 'com.google.android.gms:play-services-ads:+' 
    compile 'com.google.android.gms:play-services-analytics:+'
    ...
}

它不适用于 API 18 设备。它因错误日志而崩溃:

Could not find class 'android.app.AppOpsManager', referenced from method com.google.android.gms.common.GooglePlayServicesUtil.zza

然后我将我的设备升级到 API 19,并且成功了。所以我猜最新的 Google Play Service Library 7.8.0 正在引用 AppOpsManager,但根据 AppOpsManager (link) 的文档,它仅在 API 19 之后可用。

有任何提示可以让它在较低 API 级别的设备上工作吗?

(我必须对 Google Play 服务使用选择性编译以避免 "dex-index-overflow",并且我使用的 Dexguard 不适用于启用了 multi-dex 的 apk。)

Admob 和 Analytics 从 API 9

开始工作

试试这个:
编译 'com.google.android.gms:play-services-ads:7.8.0'