【发布时间】:2015-04-14 23:16:54
【问题描述】:
在我的 android 应用程序中,我有一个适用于 GCM 的函数 我使用 google_play_services_lib。
现在我正在实施 MapBox 地图,没有 Google 地图。
我在一个单独的项目中使用 MapBox 进行了各种测试,非常完美, 但是当我编译这两个依赖项时,应用程序不会运行。
我认为我的问题是 谷歌播放服务和地图框。
这是我的脚本和日志。 我希望你能帮助我。 谢谢。
build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
defaultConfig {
applicationId "storecheck.com.storecheck2"
minSdkVersion 9
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile ('com.mapbox.mapboxsdk:mapbox-android-sdk:0.7.1@aar'){
transitive=true
}
compile 'joda-time:joda-time:2.2'
compile 'com.google.android.gms:play-services:+'
compile 'com.android.support:appcompat-v7:20.0.0'
compile "commons-io:commons-io:+"
compile "org.apache.httpcomponents:httpmime:4.2.3"
}
日志
Information:Gradle tasks [:app:assembleDebug]
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:compileDebugNdk UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72000Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42200Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServices700Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAds700Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAnalytics700Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAppindexing700Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAppstate700Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesBase700Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesCast700Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesDrive700Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesFitness700Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesGames700Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesGcm700Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesIdentity700Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesLocation700Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesMaps700Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesNearby700Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesPanorama700Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesPlus700Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesSafetynet700Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesWallet700Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesWearable700Library UP-TO-DATE
:app:prepareComMapboxMapboxsdkMapboxAndroidSdk071Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:compileDebugJava UP-TO-DATE
:app:preDexDebug UP-TO-DATE
:app:dexDebug
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
at com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:502)
at com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:277)
at com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:491)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:168)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)
at com.android.dx.command.dexer.Main.run(Main.java:246)
at com.android.dx.command.dexer.Main.main(Main.java:215)
at com.android.dx.command.Main.main(Main.java:106)
Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/opt/java/jdk1.7.0_65/bin/java'' finished with non-zero exit value 2.
嗯,我的项目在 Android Studio 中。 我在 Eclipse 中尝试过,我下载了 MapBox 的源代码和所有依赖项。但是,该项目没有编译。
将错误显示为
"[2015-04-15 11:28:26 - Dex Loader] 无法执行 dex: 多个 dex 文件定义 Lcom/almeros/android/multitouch/TwoFingerGestureDetector;"
研究,我发现了这篇文章。
https://stackoverflow.com/a/18177694/3814000
在 cmets 中说:
"如果您有两个包含相同类名的 jar,则可能会发生此错误,例如,我有两个库:jsr311-api-1.1.1.jar 和 jersey-core-1.17.1.jar,两者都包含类 javax.ws.rs.ApplicationPath。我删除了 jsr311-api-1.1.1.jar,它工作正常。”
我认为google play services lib和map box有这个问题。
但我不确定
【问题讨论】:
-
我把 multiDexEnabled = true,但是,我的问题仍然存在。我认为是同名类link的罐子有问题@
标签: android google-play-services mapbox