2015-09-27 16 views
-2

我修改了build.gradle文件來配置multidex,我還在官方文檔中做了一個研究,但新問題是「主要dex中的方法太多」,如何減少主要DEX主要區域中有太多的方法

的build.gradle

apply plugin: 'com.android.application' 



android { 

defaultConfig { 
    compileSdkVersion 23 
    buildToolsVersion '23.0.1' 
    minSdkVersion 14 //lower than 14 doesn't support multidex 
    targetSdkVersion 23 

    // Enabling multidex support. 
    multiDexEnabled true 

} 
dexOptions { 
    jumboMode = true 

    preDexLibraries = false 
    javaMaxHeapSize "2048M" 
} 
sourceSets { 
    main { 
     manifest.srcFile 'AndroidManifest.xml' 
     java.srcDirs = ['src'] 
     resources.srcDirs = ['src'] 
     aidl.srcDirs = ['src'] 
     renderscript.srcDirs = ['src'] 
     res.srcDirs = ['res'] 
     assets.srcDirs = ['assets'] 
    } 

    // Move the tests to tests/java, tests/res, etc... 
    instrumentTest.setRoot('tests') 

    // Move the build types to build-types/<type> 
    // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ... 
    // This moves them out of them default location under src/<type>/... which would 
    // conflict with src/ being used by the main source set. 
    // Adding new build types or product flavors should be accompanied 
    // by a similar customization. 
    debug.setRoot('build-types/debug') 
    release.setRoot('build-types/release') 
    } 
    productFlavors { 
    } 
    buildTypes { 
    debug { 
     minifyEnabled false 
     proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
    } 
} 

} 


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

dependencies { 
compile 'com.android.support:multidex:1.0.1' 
} 
+0

請將的build.gradle文件添加到更新的問題 –

+0

請參閱 –

回答

0

我想你使用的是有相同的包名稱的多個依賴像compile 'com.google.android.gms:play-services:7.5.0' compile 'com.google.android.gms:play-services-wearable:7.5.0'

+0

使用appcompat和multidex我應該怎麼做? –

+0

而是使用多個dex使用'compile'c​​om.google.android.gms:play-services:7.5.0''依賴它會減少在這個頁面上看到的方法數量[https://developers.google.com/android /guides/setup](https://developers.google.com/android/guides/setup) – Satyavrat

+0

不存在同樣的問題 –