无法 运行 Android Studio 项目与 Apache POI 库
Cant run an Android Studio project with Apache POI libraries
我第二次决定尝试 Android Studio。
所以我导入了一个使用 Apache POI 库和其他库的项目。
这是我的依赖项:
compile 'com.google.http-client:google-http-client-gson:1.19.0'
compile 'com.google.code.gson:gson:2.1'
compile 'com.android.support:appcompat-v7:19.1.0'
compile 'com.google.android.gms:play-services:+'
compile files('libs/commons-codec-1.9.jar')
compile files('libs/commons-logging-1.1.3.jar')
compile files('libs/google-api-client-1.16.0-rc.jar')
compile files('libs/google-api-client-android-1.16.0-rc.jar')
compile files('libs/google-api-services-drive-v2-rev111-1.16.0-rc.jar')
compile files('libs/google-http-client-1.16.0-rc.jar')
compile files('libs/google-http-client-android-1.16.0-rc.jar')
compile files('libs/google-http-client-jackson-1.16.0-rc.jar')
compile files('libs/google-http-client-jackson2-1.16.0-rc.jar')
compile files('libs/google-oauth-client-1.16.0-rc.jar')
compile files('libs/jackson-core-2.1.3.jar')
compile files('libs/jsr305-1.3.9.jar')
compile files('libs/log4j-1.2.17.jar')
compile files('libs/poi-3.11-20141221.jar')
当我尝试 运行 时,出现以下错误:
04:27:59.765 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception.
04:27:59.766 [ERROR] [org.gradle.BuildExceptionReporter]
04:27:59.767 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong:
04:27:59.768 [ERROR] [org.gradle.BuildExceptionReporter] Execution failed for task ':app:dexDebug'.
04:27:59.769 [ERROR] [org.gradle.BuildExceptionReporter] > com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_75\bin\java.exe'' finished with non-zero exit value 2
使用 --stacktrace --info --debug 编译时,我得到:
04:27:59.754 [ERROR] [org.gradle.api.Project] AGPBI: {"kind":"SIMPLE","text":"UNEXPECTED TOP-LEVEL EXCEPTION:","position":{},"original":"UNEXPECTED TOP-LEVEL EXCEPTION:"}
AGPBI: {"kind":"SIMPLE","text":"com.android.dex.DexException: Multiple dex files define Lcom/google/api/client/util/StreamingContent;","position":{},"original":"com.android.dex.DexException: Multiple dex files define Lcom/google/api/client/util/StreamingContent;"}
我注意到当我删除 poi-3.11-20141221.jar 时一切正常。
我搜索了很长时间这个问题,但我开始厌烦它并认真考虑 return 永久 eclipse。
所以我的问题是:
我应该怎么做才能让我的项目在 Android Studio 中使用 POI 库工作?
谢谢
我明白了!!!
我意识到问题出在同一项目中使用 Apache POI、google 驱动器和 Google Play 服务库。所有这些库在我的项目中引入了太多方法。
为了避免编译错误,我只是在构建中启用了 multiDex gradle:
defaultConfig {
multiDexEnabled = true
}
而且有效!现在很开心:)
我在这里找到了这个解决方案:
Unable to execute dex: method ID not in [0, 0xffff]: 65536
我第二次决定尝试 Android Studio。 所以我导入了一个使用 Apache POI 库和其他库的项目。 这是我的依赖项:
compile 'com.google.http-client:google-http-client-gson:1.19.0'
compile 'com.google.code.gson:gson:2.1'
compile 'com.android.support:appcompat-v7:19.1.0'
compile 'com.google.android.gms:play-services:+'
compile files('libs/commons-codec-1.9.jar')
compile files('libs/commons-logging-1.1.3.jar')
compile files('libs/google-api-client-1.16.0-rc.jar')
compile files('libs/google-api-client-android-1.16.0-rc.jar')
compile files('libs/google-api-services-drive-v2-rev111-1.16.0-rc.jar')
compile files('libs/google-http-client-1.16.0-rc.jar')
compile files('libs/google-http-client-android-1.16.0-rc.jar')
compile files('libs/google-http-client-jackson-1.16.0-rc.jar')
compile files('libs/google-http-client-jackson2-1.16.0-rc.jar')
compile files('libs/google-oauth-client-1.16.0-rc.jar')
compile files('libs/jackson-core-2.1.3.jar')
compile files('libs/jsr305-1.3.9.jar')
compile files('libs/log4j-1.2.17.jar')
compile files('libs/poi-3.11-20141221.jar')
当我尝试 运行 时,出现以下错误:
04:27:59.765 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception.
04:27:59.766 [ERROR] [org.gradle.BuildExceptionReporter]
04:27:59.767 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong:
04:27:59.768 [ERROR] [org.gradle.BuildExceptionReporter] Execution failed for task ':app:dexDebug'.
04:27:59.769 [ERROR] [org.gradle.BuildExceptionReporter] > com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_75\bin\java.exe'' finished with non-zero exit value 2
使用 --stacktrace --info --debug 编译时,我得到:
04:27:59.754 [ERROR] [org.gradle.api.Project] AGPBI: {"kind":"SIMPLE","text":"UNEXPECTED TOP-LEVEL EXCEPTION:","position":{},"original":"UNEXPECTED TOP-LEVEL EXCEPTION:"}
AGPBI: {"kind":"SIMPLE","text":"com.android.dex.DexException: Multiple dex files define Lcom/google/api/client/util/StreamingContent;","position":{},"original":"com.android.dex.DexException: Multiple dex files define Lcom/google/api/client/util/StreamingContent;"}
我注意到当我删除 poi-3.11-20141221.jar 时一切正常。
我搜索了很长时间这个问题,但我开始厌烦它并认真考虑 return 永久 eclipse。
所以我的问题是: 我应该怎么做才能让我的项目在 Android Studio 中使用 POI 库工作?
谢谢
我明白了!!!
我意识到问题出在同一项目中使用 Apache POI、google 驱动器和 Google Play 服务库。所有这些库在我的项目中引入了太多方法。
为了避免编译错误,我只是在构建中启用了 multiDex gradle:
defaultConfig {
multiDexEnabled = true
}
而且有效!现在很开心:)
我在这里找到了这个解决方案: Unable to execute dex: method ID not in [0, 0xffff]: 65536