There was a problem parsing .xlsx file.

I tried to use libraries to parse files, as a result I received an error that there are too many methods in libraries (like, more than 65K).

After a brief search in Google, I came across a variant using multidex , but the project stopped compiling (already 40 minutes ...).

Here is my gradle.build file:

 apply plugin: 'com.android.application' apply plugin: 'me.tatarka.retrolambda' android { compileSdkVersion 24 buildToolsVersion "24.0.3" defaultConfig { applicationId "com.rostislav.dugin.reminderofwork" minSdkVersion 17 targetSdkVersion 24 versionCode 1 versionName "1.0" multiDexEnabled true } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') //Библиотеки для парсинга тут testCompile 'junit:junit:4.12' compile 'org.greenrobot:eventbus:3.0.0' compile 'com.android.support:appcompat-v7:24.2.1' compile 'com.android.support:design:24.2.1' compile 'io.reactivex:rxandroid:1.2.1' compile 'io.reactivex:rxjava:1.1.6' compile 'com.android.support:multidex:1.0.0' } 

Tell me, why is this happening and how to fix it?

    1 answer 1

    You can significantly speed up the project build by raising minSDKVersion to 21 (and by assembling a release build, you can lower the API Level , if it is not tied to the means used, but the build process will be the same long).

    In details:

    (With minSDKVersion less than 21 - when using Dalvik ) the project build takes a long time, because:

    It should be noted that a multidex configuration requires a complex system. It’s a rule that you can’t slow down your development process.

    In short: when building an application with multiDexEnabled true there is a long selection process: which classes should be included in the main DEX file and which ones should be included in the secondary ones.

    How to fix:

    In the case of multidex output, it’s possible to make it a bit different.

    SDK version of 21 for this development. This setting generates multidex output much faster than the ART-supported format. For the release flavor, set a minimum SDK version. This setting generates a multidex APK that is compatible with more devices, but it takes longer to build.

    In short: the solution is based on raising the minSDKVersion version to 21 , at which the project will be assembled faster (since API Level 21 replaced Dalvik with ART , which natively supports multiple dex files ).

    But if you need to support devices with less minSDKVersion , then you can use product flavors to customize different configurations:

     productFlavors { // Define separate dev and prod product flavors. dev { // dev utilizes minSDKVersion = 21 to allow the Android gradle plugin // to pre-dex each module and produce an APK that can be tested on // Android Lollipop without time consuming dex merging processes. minSdkVersion 21 } prod { // The actual minSdkVersion for the application. minSdkVersion 14 } } 

    During development, you can build the dev configuration (in which there will be minSdkVersion 21 ), and for release - the prod configuration (in which minSdkVersion will be lower). But in the release configuration, the application will, of course, last longer.

    More details can be found at the link: Configure Apps with Over 64K Methods .

    • Thank. Only something with multipledex'ом gave 100+ errors (after an hour :)). Now I will set the version before the 21st API, and then I will understand. - user189127
    • By the way, the inclusion of at least the 21st API does not work, anyway, an error about the 64k method. - user189127
    • @ bukashka101, that is, with multiDexEnabled true and minSdkVersion 21 get an error of more than 64K methods? - post_zeew
    • And what, and also multedex manually include? The documentation also says that it defaults to API 21 + ... - user189127
    • Everything turned on and earned. True issued 144 errors, but it all worked :)). - user189127