Skip to content

fix(android): remove unchecked Java compilation warnings #8529

Description

@aroviqen

Summary

Compiling the Capacitor Android library with -Xlint:unchecked reports eight
unchecked operations in the current 8.4.1 release and on main.

Reproduction

From an Android app that includes @capacitor/android@8.4.1, configure Java
compile tasks with -Xlint:unchecked and run:

./gradlew :capacitor-android:clean :capacitor-android:compileReleaseJavaWithJavac --console=plain

The default compilation emits the generic Some input files use unchecked or unsafe operations note.

Affected source

  • android/capacitor/src/main/java/com/getcapacitor/Plugin.java:679 constructs
    a raw CopyOnWriteArrayList from a List<PluginCall>.
  • android/capacitor/src/main/java/com/getcapacitor/BridgeWebChromeClient.java
    stores the permission and activity launchers as raw ActivityResultLauncher
    values, producing six unchecked calls at lines 120, 267, 298, 350, 369, and
    401.

Expected behavior

The released Android library should compile without unchecked-operation notes.
Parameterizing the collection construction and the two launcher fields should
remove the warnings without changing behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions