Anki-Android icon indicating copy to clipboard operation
Anki-Android copied to clipboard

[Cleanup] Removed Android 4.2 proguard workaround

Open n1snt opened this issue 3 years ago • 3 comments

Purpose / Description

This workaround was initially implemented for app crashing on Samsung devices on Android 4.2. We are currently only supporting API 21+ (Android 5.0) so there is no need for this workaround now & this can be removed.

Checklist

  • [x] You have a descriptive commit message with a short title (first line, max 50 chars).
  • [x] You have commented on your code, particularly in hard-to-understand areas
  • [x] You have performed a self-review of your own code
  • [ ] UI changes: include screenshots of all affected screens (in particular showing any new or changed strings)
  • [ ] UI Changes: You have tested your change using the Google Accessibility Scanner

n1snt avatar Aug 31 '22 13:08 n1snt

I'll test it with proguard enabled on a few devices & report back. Will also try to report back the differences in size in a few days. If not we can set minifyEnabled as false.

n1snt avatar Sep 02 '22 04:09 n1snt

If not we can set minifyEnabled as false.

This will likely also have an effect, as it may not strip out unused library code, so it would also need a size comparison

This stuff is really subtle!

mikehardy avatar Sep 02 '22 12:09 mikehardy

I suggest also checking if switching on R8's full mode will cause any issues. That got me a 13% reduction in APK size for free! (After I got Google to fix a bug in R8.)

Touching anything related to R8 can cause super weird crashes. You basically want to test all API versions on as many devices as possible, and you want to test as much of what the app can do as possible, especially anything related to crypto and serialization. Also a few times I got reports of crashes that I also couldn't reproduce, that was fun dealing with.

Also, enabling “minification” will IIRC enable obfuscation, which can significantly reduce APK size but also it makes tracebacks unreadable. R8 produces mappings that can be used to decode the tracebacks, and Google Play Console can also understand them. Still, not enabling obfuscation makes life a little bit easier eh.

oakkitten avatar Sep 03 '22 15:09 oakkitten

Hello 👋, this PR has been opened for more than 2 months with no activity on it. If you think this is a mistake please comment and ping a maintainer to get this merged ASAP! Thanks for contributing! You have 7 days until this gets closed automatically

github-actions[bot] avatar Nov 19 '22 16:11 github-actions[bot]

This is still useful, it just requires really careful testing. I'd prefer to have the bugfix release cycle for 2.16 done first and tackle this early in the 2.17 cycle if possible

mikehardy avatar Nov 26 '22 23:11 mikehardy

I'm a bit busy at the moment, will get back to fixing this as soon as I get some time free.

n1snt avatar Nov 27 '22 20:11 n1snt

I'll start working on this issue again as I am done with my exams now.

n1snt avatar Jan 04 '23 13:01 n1snt

So the first rule tells Proguard to keep all class attributes. The second rule tells Proguard to keep all classes that do not match a set of specified patterns, except for certain classes that are listed explicitly. The third and fourth rules tell Proguard to keep certain specific classes. The remaining rules tell Proguard to disable specific optimizations and not generate a warning or note messages for specific patterns.

n1snt avatar Jan 04 '23 13:01 n1snt

ActionBarOverflow has just been removed, so the rules related to it can go.

david-allison avatar Feb 16 '23 02:02 david-allison

Updates:

(Just started work on this again)

These lines do not seem to do anything:

-keep class !android.support.v7.view.menu.**,!android.support.design.internal.NavigationMenu,!android.support.design.internal.NavigationMenuPresenter,!android.support.design.internal.NavigationSubMenu,** {*;}
-keep public class android.support.v7.internal.view.menu.** { *; }

Because android.support packages are deprecated in favour of androidx. Source: https://developer.android.com/topic/libraries/support-library/packages

-keepattributes ** This option preserves all non-class attributes of classes and class members in the processed output. This means that all attributes except for those explicitly excluded by other directives will

-dontpreverify
-dontoptimize
-dontshrink

These lines completely disable Proguard and do not perform any optimization. These directives instruct Proguard to skip obfuscation, optimization, and preverification steps, effectively disabling Proguard.

-dontwarn **
-dontnote **

The "-dontwarn **" and "-dontnote **" directives in a Proguard configuration file instruct Proguard to suppress all warning and note messages that would otherwise be generated during the processing of the input. The "-dontwarn" directive tells Proguard not to issue warnings for any classes or members that it encounters during processing, while the "-dontnote" directive tells Proguard not to issue any informational notes.

So wasn't proguard disabled using this configuration?

Will do some size tests & report back here :)

n1snt avatar Feb 24 '23 17:02 n1snt

I believe it is mostly disabled, however I seem to remember that the debug APK vs the release APK was quite a different size indicating there is still part of the system enabled and "helping" (from perspective of reducing APK size delivered to device).

Ideally we would enable as much of it as we can, but without causing crashes - again to reduce size of transfer and install size on device

mikehardy avatar Feb 25 '23 22:02 mikehardy

In the release apk it seems like R8 mode mentioned by @oakkitten is enabled for some reason.

n1snt avatar Feb 28 '23 18:02 n1snt

Hello 👋, this PR has had no activity for more than 2 weeks and needs a reply from the author. If you think this is a mistake please comment and ping a maintainer to get this merged ASAP! Thanks for contributing! You have 7 days until this gets closed automatically

github-actions[bot] avatar Mar 14 '23 19:03 github-actions[bot]

Commenting to keep this open.

n1snt avatar Mar 15 '23 06:03 n1snt

Hello 👋, this PR has had no activity for more than 2 weeks and needs a reply from the author. If you think this is a mistake please comment and ping a maintainer to get this merged ASAP! Thanks for contributing! You have 7 days until this gets closed automatically

github-actions[bot] avatar Mar 29 '23 07:03 github-actions[bot]