2016-11-05 33 views
0

我剛剛下載了Android Studio 2.2.2,並嘗試構建示例項目。空白活動項目在我的手機上建立,部署併成功運行。使用Android Studio構建Google Maps示例項目2.2.2

然後我嘗試構建Google地圖項目。我獲得了一個API密鑰,將其複製到google_maps_api.xml,並沒有改變任何東西。然後,如果我按建設 - >生成APK,失敗,並在搖籃控制檯以下消息:

Executing tasks: [:app:assembleDebug] 

Incremental java compilation is an incubating feature. 
:app:preBuild UP-TO-DATE 
:app:preDebugBuild UP-TO-DATE 
:app:checkDebugManifest 
:app:preReleaseBuild UP-TO-DATE 
:app:prepareComAndroidSupportAnimatedVectorDrawable2500Library UP-TO-DATE 
:app:prepareComAndroidSupportAppcompatV72500Library UP-TO-DATE 
:app:prepareComAndroidSupportMediarouterV72400Library UP-TO-DATE 
:app:prepareComAndroidSupportPaletteV72400Library UP-TO-DATE 
:app:prepareComAndroidSupportSupportCompat2500Library UP-TO-DATE 
:app:prepareComAndroidSupportSupportCoreUi2500Library UP-TO-DATE 
:app:prepareComAndroidSupportSupportCoreUtils2500Library UP-TO-DATE 
:app:prepareComAndroidSupportSupportFragment2500Library UP-TO-DATE 
:app:prepareComAndroidSupportSupportMediaCompat2500Library UP-TO-DATE 
:app:prepareComAndroidSupportSupportV42500Library UP-TO-DATE 
:app:prepareComAndroidSupportSupportVectorDrawable2500Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServices980Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesAds980Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesAdsLite980Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesAnalytics980Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesAnalyticsImpl980Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesAppindexing980Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesAppinvite980Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesAuth980Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesAuthBase980Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesAwareness980Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesBase980Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesBasement980Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesCast980Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesCastFramework980Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesClearcut980Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesDrive980Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesFitness980Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesGames980Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesGass980Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesGcm980Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesIdentity980Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesIid980Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesInstantapps980Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesLocation980Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesMaps980Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesNearby980Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesPanorama980Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesPlaces980Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesPlus980Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesSafetynet980Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesTagmanager980Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesTagmanagerApi980Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesTasks980Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesVision980Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesWallet980Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesWearable980Library UP-TO-DATE 
:app:prepareComGoogleFirebaseFirebaseAnalytics980Library UP-TO-DATE 
:app:prepareComGoogleFirebaseFirebaseAnalyticsImpl980Library UP-TO-DATE 
:app:prepareComGoogleFirebaseFirebaseAuth980Library UP-TO-DATE 
:app:prepareComGoogleFirebaseFirebaseAuthCommon980Library UP-TO-DATE 
:app:prepareComGoogleFirebaseFirebaseAuthModule980Library UP-TO-DATE 
:app:prepareComGoogleFirebaseFirebaseCommon980Library UP-TO-DATE 
:app:prepareComGoogleFirebaseFirebaseConfig980Library UP-TO-DATE 
:app:prepareComGoogleFirebaseFirebaseCrash980Library UP-TO-DATE 
:app:prepareComGoogleFirebaseFirebaseDatabase980Library UP-TO-DATE 
:app:prepareComGoogleFirebaseFirebaseDatabaseConnection980Library UP-TO-DATE 
:app:prepareComGoogleFirebaseFirebaseIid980Library UP-TO-DATE 
:app:prepareComGoogleFirebaseFirebaseMessaging980Library UP-TO-DATE 
:app:prepareComGoogleFirebaseFirebaseStorage980Library UP-TO-DATE 
:app:prepareComGoogleFirebaseFirebaseStorageCommon980Library UP-TO-DATE 
:app:prepareDebugDependencies 
:app:compileDebugAidl UP-TO-DATE 
:app:compileDebugRenderscript UP-TO-DATE 
:app:generateDebugBuildConfig 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:incrementalDebugJavaCompilationSafeguard UP-TO-DATE 
:app:compileDebugJavaWithJavac UP-TO-DATE 
:app:compileDebugNdk UP-TO-DATE 
:app:compileDebugSources UP-TO-DATE 
:app:mergeDebugShaders UP-TO-DATE 
:app:compileDebugShaders UP-TO-DATE 
:app:generateDebugAssets UP-TO-DATE 
:app:mergeDebugAssets UP-TO-DATE 
:app:transformClassesWithDexForDebug FAILED 

FAILURE: Build failed with an exception. 

* What went wrong: 
Execution failed for task ':app:transformClassesWithDexForDebug'. 
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536 

* Try: 
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. 

BUILD FAILED 

Total time: 53.036 secs 

首先,我注意到「增量Java編譯是一個孵化功能」的消息。也許增量編譯是失敗的原因?如果是這樣,我該如何禁用它?我在build.gradle和其他與gradle相關的文件中沒有找到任何關於它的信息。

如果增量構建不是原因,那麼它是什麼以及如何解決它?這:

Execution failed for task ':app:transformClassesWithDexForDebug'. 
    > com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536 

看起來像一個gradle內部錯誤。我對嗎?這裏是我的build.gradle

buildscript { 
    repositories { 
     jcenter() 
    } 
    dependencies { 
     classpath 'com.android.tools.build:gradle:2.2.2' 

     // NOTE: Do not place your application dependencies here; they belong 
     // in the individual module build.gradle files 
    } 
} 

allprojects { 
    repositories { 
     jcenter() 
    } 
} 

task clean(type: Delete) { 
    delete rootProject.buildDir 
} 
+1

你可以發佈你的gradle文件嗎? – 2016-11-05 16:29:15

+0

@ 14bce109我將文件添加到我的問題。 – Sergey

+0

如果已解決,請發佈您的解決方案。我等了十多天才知道。 –

回答

2

com.android.dex.DexIndexOverflowException:方法ID不能在[0,0xFFFF的]:65536

您必須啓用multidex爲您的項目總數方法在你的版本超過65536.見Configure Apps with Over 64K Methods