【问题标题】:Adding Google play service map and location dependencies添加 Google Play 服务地图和位置依赖项
【发布时间】:2015-07-11 04:15:57
【问题描述】:

如何在你的 android 项目中同时包含地图和位置 google play 依赖项?这就是我正在做的-

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:recyclerview-v7:22.2.0'
    compile 'com.android.support:appcompat-v7:22.2.0'
    compile 'com.android.support:design:22.2.0'
    compile 'com.android.support:support-v4:22.2.0'
    compile 'com.google.maps.android:android-maps-utils:0.3.1'
    compile 'com.google.android.gms:play-services-maps:7.5.0'
    compile 'com.google.android.gms:play-services-location:7.5.0'
    compile 'com.jakewharton:butterknife:6.0.0'
    compile 'com.jakewharton.timber:timber:2.5.0'
    compile 'com.google.code.gson:gson:2.3'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.squareup.retrofit:retrofit:1.9.0'
    compile 'com.squareup.okhttp:okhttp-urlconnection:2.2.0'
    compile 'com.squareup.okhttp:okhttp:2.2.0'
    compile 'io.reactivex:rxandroid:0.24.0'
    compile('eu.inmite.android.lib:android-validation-komensky:0.9.2') {
        exclude module: 'support-v4'
    }
    compile 'com.squareup:otto:1.3.7'
    compile project(':libstreaming')
    compile('com.crashlytics.sdk.android:crashlytics:2.4.0@aar') {
        transitive = true;
    }
//    compile('com.github.nkzawa:socket.io-client:0.5.2') {
//        exclude group: 'org.json', module: 'json'
//    }

} 

这就是我得到的- 错误:任务 ':app:processDebugResources' 执行失败。

错误:多个库的包名称为“com.google.android.gms” 您可以使用 android.enforceUniquePackageName=false 暂时禁用此错误 但是,这是暂时的,将在 1.0 中强制执行

【问题讨论】:

    标签: android android-studio google-play-services


    【解决方案1】:

    play-services-location 实际上包含 play-services-maps 作为依赖项,因此您可以完全删除 maps 行。

    您可以使用./gradlew dependencies 来检查某些依赖项的确切来源 - 这可以帮助您准确缩小哪些库还包括部分 Google Play 服务 - 确保您也没有将其作为 jar 文件在您的libs 目录中。

    【讨论】:

    • 好吧,也许你是对的,但我仍然遇到同样的错误。这次是因为地图工具。
    • 编译('com.google.android.gms:play-services-location:7.8.0'){排除组:'com.google.android.gms',模块:'play-services -地图'}
    • @user949884 - 当然是play-services-maps 包含LatLng,这是位置的一个重要部分(以及底层依赖背后的原因)。
    • 我的应用不需要它。
    【解决方案2】:

    我改变了这个编译 'com.google.maps.android:android-maps-utils:0.3.1' 编译 'com.google.maps.android:android-maps-utils:0.3.4'。

    这已在地图工具的更新版本中得到修复。它有效。

    【讨论】:

      【解决方案3】:

      您只需要删除完整的播放服务依赖包并仅添加所需的依赖项,例如。如果您正在使用位置服务,请编译“com.google.android.gms:play-services-location:10.0.1”,如果您正在使用,请编译“com.google.android.gms:play-services-maps:10.0.1”使用地图服务。

      【讨论】:

        【解决方案4】:

        删除

            compile 'com.google.android.gms:play-services-maps:7.5.0'
        compile 'com.google.android.gms:play-services-location:7.5.0'
        

        并添加

        compile 'com.google.android.gms:play-services:7.0.0'
        

        【讨论】:

        • 另外你可能也不需要" compile 'com.google.maps.android:android-maps-utils:0.3.1'"
        • 我已经尝试过了,达到了 65k 的限制。因此寻找替代品。
        • 选择性地编译您需要的 API 是一种更好的方法。
        猜你喜欢
        • 2016-05-13
        • 1970-01-01
        • 1970-01-01
        • 2018-08-08
        • 1970-01-01
        • 1970-01-01
        • 2018-12-23
        • 1970-01-01
        • 2018-06-27
        相关资源
        最近更新 更多