2015-06-16 63 views
0

我在我的build.gradleAndroid編譯項目錯誤嘗試構建應用程序> 65K(65536)方法

compile 'com.android.support:appcompat-v7:22.2.0' 
compile 'com.android.support:design:22.2.0' 

而現在加入這兩個新的依賴,因爲我我不能建立我的項目我有一個錯誤。我發現有關錯誤的信息和我發現的解決方案說我必須添加...

compile 'com.parse.bolts:bolts-android:1.+' 

要myy app.gradle。我已經添加了,將OK結果同步到Gradle,但是當我要構建我的Android項目時,它不適用於我。因此,我的實際的build.gradle是...

buildscript { 
repositories { 
    maven { url 'https://maven.fabric.io/public' } 
} 

dependencies { 
    classpath 'io.fabric.tools:gradle:1.+' 
} 
} 
apply plugin: 'com.android.application' 
apply plugin: 'io.fabric' 

repositories { 
maven { url 'https://maven.fabric.io/public' } 
mavenCentral() 
} 

android { 
compileSdkVersion 22 
buildToolsVersion "22.0.1" 

defaultConfig { 
    applicationId "demo31.mobiltool" 
    minSdkVersion 15 
    targetSdkVersion 22 
    versionCode 1 
    versionName "1.0" 
} 
buildTypes { 
    release { 
     minifyEnabled false 
     proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
    } 
} 
} 

dependencies { 
compile fileTree(dir: 'libs', include: ['*.jar']) 
compile 'com.android.support:appcompat-v7:22.2.0' 
compile 'com.android.support:design:22.2.0' 

compile 'com.parse.bolts:bolts-android:1.+' 

compile 'com.android.support:support-v4:22.2.0' 
compile 'com.google.android.gms:play-services:6+' 
compile 'com.facebook.android:facebook-android-sdk:4.0.0' 
compile('com.twitter.sdk.android:twitter:[email protected]') { 
    transitive = true; 
} 
compile 'com.google.apis:google-api-services-urlshortener:v1-rev41-1.20.0' 
} 

當我嘗試建立我的Android項目,我已經得到了這些錯誤...

Information:Gradle tasks [:app:assembleDebug] 
Warning:Dependency org.apache.httpcomponents:httpclient:4.0.1 is ignored for debug as it may be conflicting with the internal version provided by Android. 
    In case of problem, please repackage it with jarjar to change the class packages 
Warning:Dependency org.apache.httpcomponents:httpclient:4.0.1 is ignored for release as it may be conflicting with the internal version provided by Android. 
    In case of problem, please repackage it with jarjar to change the class packages 
:app:preBuild UP-TO-DATE 
:app:preDebugBuild UP-TO-DATE 
:app:checkDebugManifest 
:app:preReleaseBuild UP-TO-DATE 
:app:prepareComAndroidSupportAppcompatV72220Library UP-TO-DATE 
:app:prepareComAndroidSupportDesign2220Library UP-TO-DATE 
:app:prepareComAndroidSupportSupportV42220Library UP-TO-DATE 
:app:prepareComDigitsSdkAndroidDigits150Library UP-TO-DATE 
:app:prepareComFacebookAndroidFacebookAndroidSdk400Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServices6587Library UP-TO-DATE 
:app:prepareComTwitterCobaltPerformanceMetrics020Library UP-TO-DATE 
:app:prepareComTwitterSdkAndroidTweetComposer074Library UP-TO-DATE 
:app:prepareComTwitterSdkAndroidTweetUi120Library UP-TO-DATE 
:app:prepareComTwitterSdkAndroidTwitter151Library UP-TO-DATE 
:app:prepareComTwitterSdkAndroidTwitterCore134Library UP-TO-DATE 
:app:prepareIoFabricSdkAndroidFabric131Library 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:fabricGenerateResourcesDebug 
:app:processDebugResources 
:app:generateDebugSources 
:app:processDebugJavaRes UP-TO-DATE 
:app:compileDebugJava UP-TO-DATE 
:app:compileDebugNdk UP-TO-DATE 
:app:compileDebugSources 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 '/usr/lib/jvm/java-7-openjdk-amd64/bin/java'' finished with non-zero exit value 2** 

我在做什麼錯?我有什麼要添加,刪除或修改以正確構建我的項目?

回答

1

您需要減小尺寸或僅包含您需要的用於應用程序的導入。您正在達到65536個方法的dex限制。

這裏是鏈接Building Apps with Over 65K Methods這可能會有所幫助。

+0

它的工作原理! @Ramandeep Nanda你救了我的命!非常感謝您的出色幫助! –

相關問題