无法同时添加 Google Play 服务和 Appcompat-v7 依赖项
Can't add both Google Play Services and Appcompat-v7 dependencies
我正在尝试清理和更新项目中的库。作为其中的一部分,我从使用经典库文件夹依赖项转变为 gradle,用于 Google Play 服务。我在编译调试时开始收到 dexDebug 错误(请参阅 Android Studio - UNEXPECTED TOP-LEVEL EXCEPTION: )。据我了解,如果您以某种方式存在双重依赖,则会出现此错误。
下面是我的 gradle 文件的依赖项部分。如果我完全注释掉 appcompat-v7,一切正常。 play-services 是否已经依赖于 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')
}
事实证明这个问题完全重复:
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,用于 Google Play 服务。我在编译调试时开始收到 dexDebug 错误(请参阅 Android Studio - UNEXPECTED TOP-LEVEL EXCEPTION: )。据我了解,如果您以某种方式存在双重依赖,则会出现此错误。
下面是我的 gradle 文件的依赖项部分。如果我完全注释掉 appcompat-v7,一切正常。 play-services 是否已经依赖于 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')
}
事实证明这个问题完全重复:
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')
}