What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To keep reflection and serialization working after obfuscation, preserve only the classes, members, and metadata that runtime code actually discovers—and test the transformed release build. There is no universally safe ProGuard or R8 rule: the right configuration depends on the runtime, obfuscator and mode, serializer, library versions, and whether dependencies already provide keep rules.

Start by identifying the exact stack

Before writing a rule, record the runtime and platform, obfuscator and its mode, serializer and version, and whether libraries supply consumer rules. The Android examples below apply to R8 and are starting points, not copy-paste rules for an unspecified app. The .NET example concerns a separate trimming behavior; Android keep syntax does not apply to it.

Inventory what runtime code discovers

Static analysis can miss reflection when a program builds class or member names dynamically. A shrinker may remove something that appears unused, or rename it so a string-based lookup no longer matches. For each reflective entry point, write down what must remain stable: the class or member’s presence, its name, its constructor, annotations, generic signature, or another piece of metadata.

  • Search for Class.forName, reflective constructor calls, and getDeclaredField or getDeclaredMethod.
  • Find annotation scans, serializer model fields, generic type tokens, JNI upcalls, and framework callbacks or convention-based method calls.
  • For plugin or dependency loading, determine whether code identifies implementations by class name, interface, registration metadata, or another mechanism.

Android’s keep-rules guide covers class-by-name lookup, annotation-based access, private reflected members, and Parcelable patterns. These mechanisms need not all be preserved in the same way.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

Choose the narrowest Android keep rule that fits

R8 rules control different things. A -keep rule can stop matched items from being removed or renamed; -keepclassmembers preserves matched members only on classes that remain. A narrower rule can leave more shrinking and optimization available than keeping an entire class and all its members. See Android’s keep-rule reference for rule behavior and scope.

Class found by a name string

If code loads a class by a literal or constructed string and invokes its no-argument constructor, preserve that class and constructor under the name the lookup expects. If lookup instead selects implementations of a shared interface, a rule aimed at those implementations and constructors may be narrower than retaining every application class. Verify which class names the runtime actually requests.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

Specific field or method found by name

When code looks up a member by a literal name, preserve that member on its exact declaring class, with the correct signature and name. Do not default to -keep class X { *; } if only one member is required: broad rules can constrain optimization unnecessarily. Annotation scans also need their relevant annotations and annotated elements to survive as required by the framework.

Conditional model rules

Where models can be identified by a marker such as fields annotated with @SerializedName, a conditional or annotation-based rule can target only matching models or members. The appropriate pattern depends on the R8 and Gson versions; consult Android’s library optimization guidance and check what the library already contributes before adding app rules.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

Gson with R8: check annotations, constructors, and signatures

Android’s current guidance says Gson 2.11 and later bundle rules for fields annotated with @SerializedName. Check the version actually resolved by the project and inspect bundled rules before maintaining redundant app rules. An explicit serialized name can mean the source field name does not need to remain unchanged, but confirm the model and serializer behavior rather than assuming.

Constructor requirements are a separate part of the contract: if deserialization relies on a constructor, ensure it remains available as needed. In R8 full mode, Android’s Gson example also requires the generic Signature attribute for a TypeToken pattern. Keep that metadata when the pattern needs it, and add other attributes only when the runtime or library requires them. Follow the version-specific Android Gson guidance rather than applying a generic rule to every project.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

Account for generated Android code and Parcelable

@Parcelize generates rules automatically, according to Android’s reference guide. A manual Parcelable implementation may need its CREATOR field preserved. Check whether generated or dependency-provided consumer rules already cover the project before duplicating them.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

.NET 8 trimming is a different configuration problem

Obfuscation and trimming are related transformations, but they are not interchangeable. Microsoft documents that .NET 8 projects using PublishTrimmed turn off reflection-based System.Text.Json defaults, which can break reflection-based serialization. Microsoft’s .NET 8 compatibility note documents the JsonSerializerIsReflectionEnabledByDefault project property for restoring the previous behavior when reflection is required. Evaluate that choice against the current target-framework guidance and consider source-generated serialization where appropriate; Android keep rules do not solve this .NET behavior.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

Validate the transformed artifact

Test a release-like build made with the same shrinker or obfuscator settings used for release. Tests against an untransformed debug build do not establish that reflection or serialization still works after transformation.

  1. Build with the intended release configuration and tool mode.
  2. Exercise serialization and deserialization, including round trips for relevant models and generic types.
  3. Exercise reflective class discovery, constructor invocation, and member access, plus optional dependency or plugin loading and framework callbacks used by the app.
  4. If a path fails, inspect shrinker diagnostics and mapping or removal outputs to determine what was removed or renamed. Adjust the narrow rule for that contract and rebuild.
  5. Keep tests tied to the actual transformed artifact and dynamic paths the application uses. Passing tests provide evidence for those paths and settings, not a guarantee for every runtime path.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.