YouTube

Got a YouTube account?

New: enable viewer-created translations and captions on your YouTube channel!

English subtitles

← Multi Deck Support

Get Embed Code
4 Languages

Showing Revision 3 created 05/24/2016 by Udacity Robot.

  1. In this project we've got
    something a little bit silly.
  2. We've got 100 classes,
    each of which have 700 methods.
  3. Well this is clearly
    a contrived example.
  4. In principle there is nothing stopping
    a large project from getting this big
  5. especially if you have
    a lot of big dependencies.
  6. So, let's try compiling this.
  7. Oops, looks like we've got an error.
  8. Trouble writing output.
  9. Too many method references.
  10. 70,000, max is 65,000.
  11. Let's unpack what's going on here.
  12. The Android virtual machine doesn't
    actually run Java byte code.
  13. It runs Dalvik byte code.
  14. And there's a build step
    after java compilation,
  15. where the Java byte code is
    turned into Dalvik byte code.
  16. The step is called dexing.
  17. Part of this process is compiling
    a table of every method
  18. in the application,
    which is then indexed with two bytes.
  19. So, that means we're
    limited to 65K methods.
  20. Fortunately, we can ask gradleto simply
    break up this table into multiple tables
  21. by setting in our build.gradle
    file under default config,
  22. multiDexEnabled true.
  23. Now if we try and build again, looking
    through our build log we see that
  24. the dex process was run successfully,
    so now we're building just fine,
  25. even though our project is gigantic.
  26. This is just something to be aware of so
    you don't get bit by this in the future.