【问题标题】:Can't add both Google Play Services and Appcompat-v7 dependencies无法同时添加 Google Play 服务和 Appcompat-v7 依赖项
【发布时间】:2015-04-02 05:29:07
【问题描述】:

我正在尝试清理和更新项目中的库。作为其中的一部分,我从使用经典库文件夹依赖项转移到通过 gradle 使用 Google Play 服务。我在编译调试时开始收到 dexDebug 错误(请参阅 Android Studio - UNEXPECTED TOP-LEVEL EXCEPTION: )。据我了解,如果您以某种方式具有双重依赖关系,则会出现此错误。

下面是我的 gradle 文件的依赖部分。如果我完全注释掉 appcompat-v7,一切正常。播放服务是否已经依赖于 appcompatv7 并自动将其引入或发生了什么?

dependencies {
compile 'com.google.android.gms:play-services:7.0.0'
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.google.maps.android:android-maps-utils:0.3'

//compile files('libs/commons-codec-1.8-sources.jar')
compile files('libs/engine.io-client-0.2.3.jar')
compile files('libs/ffmpeg.jar')
compile files('libs/Java-WebSocket-1.3.0.jar')
compile files('libs/socket.io-client-0.1.3.jar')
//compile files('libs/javacpp.jar')
compile files('libs/javacv.jar')
compile files('libs/json-simple-1.1.1.jar')
compile files('libs/opencv.jar')
//compile files('libs/twitter4j-async-4.0.2.jar')
compile files('libs/twitter4j-core-4.0.2.jar')
//compile files('libs/twitter4j-media-support-4.0.2.jar')
//compile files('libs/twitter4j-stream-4.0.2.jar')

}

【问题讨论】:

    标签: android gradle google-play-services android-appcompat


    【解决方案1】:

    原来这个问题有一个完全相同的重复:

    After update of AS to 1.0, getting "method ID not in [0, 0xffff]: 65536" error in project

    我通过添加来修复它(仅此一项就可以解决原来的问题):

    defaultConfig {
        ...
        multiDexEnabled true
    }
    

    并通过削减大量的 Google Play 服务,并仅使用其中的一部分(仅此一项也可以解决原始问题):

    dependencies {
    //compile 'com.google.android.gms:play-services:7.0.0'
    compile 'com.google.android.gms:play-services-maps:7.0.0'
    compile 'com.google.android.gms:play-services-location:7.0.0'
    compile 'com.google.android.gms:play-services-gcm:7.0.0'
    compile 'com.google.android.gms:play-services-plus:7.0.0'
    compile 'com.android.support:appcompat-v7:22.0.0'
    compile 'com.google.maps.android:android-maps-utils:0.3+'
    
    compile files('libs/engine.io-client-0.2.3.jar')
    compile files('libs/ffmpeg.jar')
    compile files('libs/Java-WebSocket-1.3.0.jar')
    compile files('libs/socket.io-client-0.1.3.jar')
    compile files('libs/javacv.jar')
    compile files('libs/json-simple-1.1.1.jar')
    compile files('libs/opencv.jar')
    compile files('libs/twitter4j-core-4.0.2.jar')
    

    }

    【讨论】:

    • 慢下来。你不想要多索引。从库隐藏到 Gradle 依赖(Gradle 和 Maven 的全部意义)。
    • 好吧,我确实为大公司、Google Play 服务和 appcompat-v7 这样做了,然后我遇到了这个问题。我正在用我所做的其他事情更新我的答案(减少 Google Play 服务)
    猜你喜欢
    • 2015-12-21
    • 2016-05-13
    • 1970-01-01
    • 2014-10-05
    • 1970-01-01
    • 2019-05-20
    • 1970-01-01
    • 2018-08-08
    • 1970-01-01
    相关资源
    最近更新 更多