添加GCM后端时,Android应用构建失败

时间:2015-12-15 14:28:06

标签: java android google-app-engine dex

我想在我的Android应用程序中添加Google Cloud Messaging后端(只是其中一个可用的示例)。为此,我正在关注官方documentation。我正在我的手机上部署(带有Android 5.0.2的三星A5)

在添加后端之前,可以正常部署应用程序。

添加后端后,后端可以正常部署在Google AppEngine开发服务器上,我可以在浏览器中看到它。

但是,当我尝试在我的设备上部署应用程序时,我最终得到了错误。

是否与我的Java版本(1.8)有关?

我注意到堆栈跟踪中提到了dex,所以它可能与method number limit有关吗?我不希望这样,因为它是一个非常小的示例应用程序,我认为我可能没有超过64K方法。

最后,我找到了类似的question,但它没有用。

Information:Gradle tasks [:app:assembleDebug]
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:backend:appengineDownloadSdk
:backend:compileJava UP-TO-DATE
:backend:processResources UP-TO-DATE
:backend:classes UP-TO-DATE
:backend:appengineEndpointsGetClientLibs UP-TO-DATE
:backend:appengineEndpointsExpandClientLibs UP-TO-DATE
:backend:compileEndpointsSrcJava UP-TO-DATE
:backend:processEndpointsSrcResources UP-TO-DATE
:backend:endpointsSrcClasses UP-TO-DATE
:backend:_appengineEndpointsAndroidArtifact UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72311Library UP-TO-DATE
:app:prepareComAndroidSupportDesign2311Library UP-TO-DATE
:app:prepareComAndroidSupportMediarouterV72220Library UP-TO-DATE
:app:prepareComAndroidSupportRecyclerviewV72311Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42311Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServices830Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAds830Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAnalytics830Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAppindexing830Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAppinvite830Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAppstate830Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAuth830Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesBase830Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesBasement830Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesCast830Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesDrive830Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesFitness830Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesGames830Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesGcm830Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesIdentity830Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesLocation830Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesMaps830Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesMeasurement830Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesNearby830Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesPanorama830Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesPlus830Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesSafetynet830Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesVision830Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesWallet830Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesWearable830Library 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:compileDebugJavaWithJavac UP-TO-DATE
:app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources UP-TO-DATE
:app:transformClassesWithDexForDebug
UNEXPECTED TOP-LEVEL EXCEPTION:
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home/bin/java'' finished with non-zero exit value 2
Information:BUILD FAILED
Information:Total time: 2 mins 44.821 secs
Information:1 error
Information:0 warnings
Information:See complete output in console

1 个答案:

答案 0 :(得分:1)

我按照wadali的建议检查了questionA.Grandt的答案对我有用,说:

  

另一件需要注意的事情是,你不能使用

compile 'com.google.android.gms:play-services:8.3.0'
     

这将导入所有播放服务,并且它只需要比hello世界多一点,超过单个dex APK的65535方法限制。

     

始终只指定您需要的服务

所以我只保留了这个:

compile 'com.google.android.gms:play-services-gcm:8.3.0'