2015-04-02 93 views
2

我正在清理并更新项目上的库。作为此操作的一部分,我将Google Play服务从经典库文件夹依赖关系转移到Gradle中。编译调试时,我开始出现dexDebug错误(请参阅Android Studio - UNEXPECTED TOP-LEVEL EXCEPTION:)。根据我的理解,如果您有某种双重依赖性,则会显示此错误。无法添加Google Play服务和Appcompat-v7依赖关系

下面是我的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') 

}

回答

3

原来有一个确切的重复这个问题:

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

我加入(单独这将解决原来的问题)固定它:

defaultConfig { 
    ... 
    multiDexEnabled true 
} 

并削减了大量的Google Pl AY服务,以及使用它的唯一子集(就凭这也将解决原来的问题):

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') 

}

+0

慢下来。你不想要multidex。从libs到Gradle depdenencies(Gradle和Maven的全部点)的隐藏。 – 2015-04-02 17:19:31

+0

好吧,我确实为大型游戏,Google Play服务和appcompat-v7做了这些,然后我遇到了这个问题。我正在更新自己的答案(减少了Google Play服务) – Flyview 2015-04-02 19:10:14