We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

OutOfMemoryExceptions and maximum methods limit in a dex file

We are considering Aspose for our product and testing the free trial at the moment. We have had some success building Aspose Words into our app in Android Studio, but success with Aspose Cells is proving elusive!

In order to prevent clashes between Words and Cells, we first added the following packaging options:
packagingOptions {
This masked an OutOfMemoryException we then saw during compilation. We solved this by editing the studio.exe.vmoptions file to increase the max, and adding the following dex option:
dexOptions {
javaMaxHeapSize "4g"
This, in turn, was masking the 64K .dex file method limit, which we are now faced with!

A quick scan of the forums shows that advice in the past has been to use Eclipse/ADT rather than Android Studio (due to its early instablities and inssues), but the situation has changed since then - and Eclipse/ADT is no longer a viable option.

What can you suggest? I'm sure you understand our ability to get this working is pretty crucial, and will lead us to purchase a license if we can get things running.


Thanks for providing us some details.

I think, on Android, there is a limitation, i.e., the number of methods allowed in Android projects. Combined number of methods in two Aspose APIs exceeds this limit of 65536 so you might see ‘Unable to execute dex: method ID …: 65536’ exception. We are gradually reducing number of methods in all the Aspose APIs working on Android. In the meantime, you can try to use a tool like https://github.com/mmin18/Dex65536 to try to overcome this issue in Android APIs.

Furthermore, try to browse and get some online help regarding your issue to sort out things, e.g

Thank you.

Thanks for the fast response!

It turns out the solution for us was a multidex configuration:

The evaluation continues…


Good to know that your have sorted out your issue now. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.

Thank you.

I’m afraid this isn’t quite over! On building my APK, Android Studio has now been dexing for about 2 hours and showing no signs of progress… Do you have any further suggestions?


We will try to evaluate your issue. Please see the thread for your reference (you could try some options/approaches mentioned in the thread) if it helps to sort out your issue:

Thank you.

Thanks - the latest build failed with an OutOfMemoryException after about 2 hours. I’ve added a preDexLibraries false to my dexOptions in build.gradle for this module… Here’s what it looks like now:

dexOptions {
preDexLibraries false
incremental true
javaMaxHeapSize “4g”
I’d also boosted the max RAM available to Android Studio (through the .vmoptions file) - up to about 2Gb.

I suspect setting preDexLibraries to false would only save me some computation if the dexing had been done, though…

It’s running again now, “Dexing in-progress.” so we’ll see!

Hi - I have finally succeeded in building my project with a working combination of Aspose Words and Aspose Cells for Android.

There were a lot of workarounds. I have documented the entire process here:

  • [Android Studio vs. Aspose for Android](http://instantiatorgratification.blogspot.co.uk/2016/04/android-studio-vs-aspose-for-android.html)

Feel free to plunder the document linked from there for advice for your users!

Hi Lewis Westbury,

We really appreciate your work to cope with the possible issues that might occur while using Aspose.Words and Aspose.Cells Android APIs together. I think your article would be helpful for the users who want to use different Aspose Android APIs in an Android Studio project.

Furthermore, we think we need to make our Android APIs revamped to minimize such issues. Some progress is already made to accomplish the task.

Thank you.

I had this problem, too, and was very happy to find my solution was just adding “multiDexEnabled true” to the project build.gradle.

Hi Daniel,

Thanks for sharing the feedback.

We are glad to hear that while adding above stated property, your problem is resolved and we hope that it will also benefit other customers, facing similar problem.

Please do let us know, if we can be of any related assistance.