mit-cml / appinventor-sources

MIT App Inventor Public Open Source
http://appinventor.mit.edu/appinventor-sources/
Apache License 2.0
1.47k stars 2.06k forks source link

More than Sufficient classes in MainDexList produces Dex Error #2344

Open rupeshkumar22 opened 3 years ago

rupeshkumar22 commented 3 years ago

Bug Description I doubted that more classes in the Main Dex List file (main-classes.txt) produce errors as it must not exceed the 65k methods limit which is mentioned in the official Android developer's documents(https://developer.android.com/studio/command-line/d8).

Testing with 8 Screens with some palette resources and setting dex verbose to true showed the following error.

MainDexListCapacityError

A tool to track the method count from classes.dex - https://github.com/mihaip/dex-method-counts The error may occur in large-sized projects with increased methods limit for the main dex.

Affects

Some alternatives we can choose to improve(Need Reviews to work on this issue) One of the following alternatives can fix the issue-

ewpatton commented 3 years ago

Can you provide an AIA file that exhibits the problem?

Sent from my iPhone

On Dec 3, 2020, at 22:05, Rupesh Kumar notifications@github.com wrote:

 Bug Description I doubted that more classes in the Main Dex List file (main-classes.txt) produce errors as it must not exceed the 65k methods limit according to the official Android developer's documents(https://developer.android.com/studio/command-line/d8).

Testing with 8 Screens with some palette resources and setting dex verbose to true showed the following error.

A tool to track the method count from classes.dex - https://github.com/mihaip/dex-method-counts

Affects

Designer Blocks editor Companion Compiled apps Buildserver Debugging Other... (please describe) Some alternatives we can choose to improve(Need Reviews to work on this issue) One of the following alternatives can fix the issue-

Excluding user-created class description in main dex list: Including only first screen classes in Primary dex list as it loads initially and skipping all the other classes. By doing this, the speed of booting up screens can't degrade more than some nanoseconds which are negligible. Class description for other crucial jars in the input set(mainly responsible for creating main-classes.txt) will make the list non-incremental and will be risk-free. We can choose to perform this method only if we identify exceed main dex list capacity during dex task compilation

Generating Main dex list: We can generate the main dex list with the help of dex list generator library and proguard. Proguard also provides options for shrinking and obfuscations. An example of dex list generator can be found in the android maven plugin build.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

rupeshkumar22 commented 3 years ago

Sure Here it is - CheckDex.zip I added thousands of palette resources by automating a drag and drop task with a tool. The idea was to increase the size of user-created sources to test the dex task behavior.