Can't fit requested classes

If I try to compile the attached project, I get the error below. It happens on both, device and emulator.

Archive.zip (702.2 KB)

Curious. D8 should automatically multi-dex and split the code in pieces (.dex files have a silly size ,limit of, IIRC, 64k methods total. each).

Quick workaround, turn off UseD8, and turn in MultiDex.

If Found MultiDex in project settings but couldn’t find where to turn of UseD8 (Fire .2505). Or does turning on MultiDex automatically mean UseD8 is off?

UseD8 should be exposed as option. In fact MultiDex should be hidden when UseD8 is on (but it seemingly is to; will fix that):

That said, true something else: create a text file that lists your main class(es) (plain text file, one full class name per line AFAIK), and pick it for the AndroidMainDexListFile project setting. see if that solves the issue.

As a side note, what seems to be causing this limit to be hit (since this is just your .jar, not any dependencies) is all the R classes from all the dependencies. I’s starting to wonder whether these should actually be compiled in for not… I’ll try making that optional for tomorrow’s build.

Turning MultiDex on and UseD8 of works for emulator (API 29). For debugging I have an older device with API 14 and it fails there. Given that MultiDex is available as of API 21 that would make sense, right?. Is there any trick to make it work on API 14 (not multi dexing but compiling with UseD8)? In Android Studio I can compile API 14 project with these dependencies.

Right, below 21 you need to jump to hoops to make multi-dex work, according to Google: Enable multidex for apps with over 64K methods  |  Android Studio  |  Android Developers.

Try adding the MainDexList, and use D8

Thank you.

I think dropping the extra R.java files fixes the issue, I’ll get that into tomorrow’s build.