Skip to content

uraniborg/Hubble: Housekeeping on build params and deprecations.#4

Merged
billy-lau merged 1 commit into
android:mainfrom
billy-lau:uraniborg/gradle-cleanup
May 11, 2026
Merged

uraniborg/Hubble: Housekeeping on build params and deprecations.#4
billy-lau merged 1 commit into
android:mainfrom
billy-lau:uraniborg/gradle-cleanup

Conversation

@billy-lau
Copy link
Copy Markdown
Member

  • 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

- 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
@billy-lau billy-lau merged commit 1b4b45d into android:main May 11, 2026
2 checks passed
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +20 to +21
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant