2016-06-13 48 views
0

我得到一個錯誤,當我將建立一個簽名的apk。我已經做了很多事情,但沒有任何幫助...我會發布帶有錯誤的消息。也許是我的錯?錯誤,當我將建立一個簽名的apk

Information:Gradle tasks [:app:assembleRelease] 
:app:preBuild UP-TO-DATE 
:app:preReleaseBuild UP-TO-DATE 
:app:checkReleaseManifest 
:app:preDebugBuild UP-TO-DATE 
:app:prepareComAndroidSupportAnimatedVectorDrawable2340Library UP-TO-DATE 
:app:prepareComAndroidSupportAppcompatV72340Library UP-TO-DATE 
:app:prepareComAndroidSupportDesign2340Library UP-TO-DATE 
:app:prepareComAndroidSupportMediarouterV72300Library UP-TO-DATE 
:app:prepareComAndroidSupportRecyclerviewV72340Library UP-TO-DATE 
:app:prepareComAndroidSupportSupportV42340Library UP-TO-DATE 
:app:prepareComAndroidSupportSupportVectorDrawable2340Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServices902Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesAds902Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesAdsLite902Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesAnalytics902Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesAnalyticsImpl902Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesAppindexing902Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesAppinvite902Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesAuth902Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesAuthBase902Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesBase902Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesBasement902Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesCast902Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesDrive902Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesFitness902Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesGames902Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesGcm902Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesIdentity902Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesIid902Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesLocation902Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesMaps902Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesNearby902Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesPanorama902Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesPlus902Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesSafetynet902Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesTagmanager902Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesTagmanagerApi902Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesTasks902Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesVision902Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesWallet902Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesWearable902Library UP-TO-DATE 
:app:prepareComGoogleFirebaseFirebaseAnalytics902Library UP-TO-DATE 
:app:prepareComGoogleFirebaseFirebaseAnalyticsImpl902Library UP-TO-DATE 
:app:prepareComGoogleFirebaseFirebaseAuth902Library UP-TO-DATE 
:app:prepareComGoogleFirebaseFirebaseAuthCommon902Library UP-TO-DATE 
:app:prepareComGoogleFirebaseFirebaseAuthModule902Library UP-TO-DATE 
:app:prepareComGoogleFirebaseFirebaseCommon902Library UP-TO-DATE 
:app:prepareComGoogleFirebaseFirebaseConfig902Library UP-TO-DATE 
:app:prepareComGoogleFirebaseFirebaseCrash902Library UP-TO-DATE 
:app:prepareComGoogleFirebaseFirebaseDatabase902Library UP-TO-DATE 
:app:prepareComGoogleFirebaseFirebaseDatabaseConnection902Library UP-TO-DATE 
:app:prepareComGoogleFirebaseFirebaseIid902Library UP-TO-DATE 
:app:prepareComGoogleFirebaseFirebaseMessaging902Library UP-TO-DATE 
:app:prepareComGoogleFirebaseFirebaseStorage902Library UP-TO-DATE 
:app:prepareComGoogleFirebaseFirebaseStorageCommon902Library UP-TO-DATE 
:app:prepareReleaseDependencies 
:app:compileReleaseAidl 
:app:compileReleaseRenderscript 
:app:generateReleaseBuildConfig 
:app:mergeReleaseShaders 
:app:compileReleaseShaders 
:app:generateReleaseAssets 
:app:mergeReleaseAssets 
:app:generateReleaseResValues 
:app:generateReleaseResources 
:app:mergeReleaseResources 
:app:processReleaseManifest 
:app:processReleaseResources 
:app:generateReleaseSources 
:app:incrementalReleaseJavaCompilationSafeguard 
:app:compileReleaseJavaWithJavac 
:app:compileReleaseJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.). 
:app:compileReleaseNdk UP-TO-DATE 
:app:compileReleaseSources 
:app:lintVitalRelease 
:app:prePackageMarkerForRelease 
:app:transformClassesWithDexForRelease 
To run dex in process, the Gradle daemon needs a larger heap. 
It currently has approximately 910 MB. 
For faster builds, increase the maximum heap size for the Gradle daemon to more than 2048 MB. 
To do this set org.gradle.jvmargs=-Xmx2048M in the project gradle.properties. 
For more information see https://docs.gradle.org/current/userguide/build_environment.html 
Error:The number of method references in a .dex file cannot exceed 64K. 
Learn how to resolve this issue at https://developer.android.com/tools/building/multidex.html 
:app:transformClassesWithDexForRelease FAILED 
Error:Execution failed for task ':app:transformClassesWithDexForRelease'. 
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/bin/java'' finished with non-zero exit value 2 
Information:BUILD FAILED 
Information:Total time: 2 mins 41.454 secs 
Information:2 errors 
Information:0 warnings 
Information:See complete output in console 

這些都是錯誤

錯誤1:

Error:The number of method references in a .dex file cannot exceed 64K. 
Learn how to resolve this issue at https://developer.android.com/tools/building/multidex.html 

錯誤2:

Error:Execution failed for task ':app:transformClassesWithDexForRelease'. 
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/bin/java'' finished with non-zero exit value 2 

我希望有人能幫助我解決這個可怕的錯誤

+1

錯誤:方法引用的一個.DEX文件不能超過64K的數量。 通過https://developer.android.com/tools/building/multidex.html瞭解如何解決此問題 – kosa

+0

^以及在項目gradle.properties中執行此操作設置org.gradle.jvmargs = -Xmx2048M ' –

+0

或者,修復您的Google Play服務依賴關係,使其不包含所有**。請參閱本頁上的第二個藍色框。 https://developers.google.com/android/guides/setup#add_google_play_services_to_your_project –

回答

1

的錯誤1明確表示w理由是帽子。這裏是解決方案

查看您的應用程序的直接和傳遞依賴關係 - 確保您包含在應用程序中的任何大型庫依賴項的使用方式超過了將被添加到應用程序的代碼量。一種常見的反模式是包含一個非常大的庫,因爲少數實用方法是有用的。減少應用程序代碼依賴性通常可以幫助您避免dex引用限制。

使用ProGuard刪除未使用的代碼 - 爲您的應用程序配置ProGuard設置以運行ProGuard,並確保您已啓用收縮版本的縮小功能。啓用收縮功能可確保您不會將未使用的代碼與APK一起發送。

而且在你的build.gradle添加此

defaultConfig { 
// Other settings here 
multiDexEnabled true 
} 
+0

只有'multiDexEnabled true'不啓用Multidex,儘管 –

+0

有幫助!謝謝!! – Hessel