uraniborg/Hubble: Housekeeping on build params and deprecations.#4
Conversation
- fixed propName = value warning in app/build.gradle.
- upgraded the project to Java 17 compatibility to resolve the JDK 22
deprecation warning.
- added suppressions in PackageMetadata.java and MainActivity.java for
APIs that are used intentionally for backward compatibility.
Test: Manual. `gradlew assemble` builds Hubble APK successfully without
further warnings now.
Change-Id: Ia390e790e26ff352635215fd211447f902e78e39
There was a problem hiding this comment.
Code Review
This pull request updates the project's Java compatibility to version 17, enables deprecation linting in the build configuration, and adds several @SuppressWarnings("deprecation") annotations to existing methods. Feedback indicates that targeting Java 17 without core library desugaring may cause runtime crashes on devices running older Android versions. Furthermore, it is recommended to apply deprecation suppressions more narrowly to specific statements rather than entire methods to prevent masking other deprecated API calls.
| sourceCompatibility JavaVersion.VERSION_17 | ||
| targetCompatibility JavaVersion.VERSION_17 |
There was a problem hiding this comment.
Using JavaVersion.VERSION_17 for targetCompatibility with a minSdkVersion of 23 can lead to runtime crashes (such as VerifyError) on older devices (pre-Android 12) because Java 17 bytecode features are not natively supported by older Android runtimes. Since core library desugaring is not enabled in this project, it is safer to use VERSION_11 or ensure that desugaring is configured to handle the higher bytecode version on older ART runtimes.
| // this allows us to get APEX packages when calling getInstalledPackages | ||
| final int MATCH_APEX = 0x40000000; | ||
|
|
||
| @SuppressWarnings("deprecation") |
There was a problem hiding this comment.
The @SuppressWarnings("deprecation") annotation is applied at the method level. This is a broad suppression that can hide other deprecated API usages introduced in the future. It is recommended to apply this annotation as narrowly as possible, such as on the specific variable declaration or statement that triggers the warning (e.g., the getInstalledPackages call).
| * @param packageManager A valid {@link PackageManager} object used to load app description. | ||
| * @return a valid {@link PackageMetadata} object containing parsed information about the APK. | ||
| */ | ||
| @SuppressWarnings("deprecation") |
There was a problem hiding this comment.
Applying @SuppressWarnings("deprecation") to this entire factory method is too broad. Since the method contains significant logic, it is better to localize the suppression to the specific blocks or variables where deprecated APIs (such as PackageInfo.versionCode) are accessed. This ensures that other parts of the method remain subject to compiler checks for deprecations.
Test: Manual.
gradlew assemblebuilds Hubble APK successfully withoutfurther warnings now.
Change-Id: Ia390e790e26ff352635215fd211447f902e78e39