如果在eclipse上使用google-play-services.jar,最新的有5m多,很多的类库我们使用不到,这样在工程上就容易报65k,具体log如下:
[2016-11-21 17:43:13 - Dex Loader] Unable to execute dex: method ID not in [0, 0xffff]: 65536
[2016-11-21 17:43:13 - MHUniSDKExample] Conversion to Dalvik format failed: Unable to execute dex: method ID not in [0, 0xffff]: 65536
如果使用的Android studio请使用google推荐的 com.android.support:multidex
eclipse的这里:精简 ads、pay、g+用到的库
1、需要用到gradle来构建
2、在build.gradle加上
task repack(){
tasks.create(name: "GDPlayServices", type: Jar) {
destinationDir = new File("/test")//生成新的jar包的存储位置
archiveName = "google-play-services-gd.jar" //新jar包的名称
from(zipTree(new File("/test/google-play-services.jar"))) {
//用到的package
include "com/google/android/gms/wearable/**"
include "com/google/android/gms/common/**"
include "com/google/android/gms/internal/**"
include "com/google/android/gms/wallet/**"
include "com/google/android/gms/plus/**"
include "com/google/android/gms/auth/**"
include "com/google/android/gms/identity/intents/**"
include "com/google/android/gms/signin/internal/**"
include "com/google/ads/**"
include "com/google/android/gms/ads/**"
include "com/google/android/gms/analytics/**"
include "com/google/android/gms/gcm/**"
}
}.execute()
}
//gradlew repack
3、在Terminal中执行
gradlew repack