Skip to content

Conversation

Copy link

Copilot AI commented Jan 13, 2026

Summary

Removes fbjni dependencies entirely from Android build configuration by converting all JNI layers (including training module) to pure JNI.

Gradle changes:

  • Remove com.facebook.fbjni:fbjni:0.7.0 dependency from executorch_android/build.gradle
  • Remove unused fbjniJavaOnlyVersion and soLoaderNativeLoaderVersion variables from root build.gradle
  • Retain com.facebook.soloader:nativeloader:0.10.5 (still used for native library loading)

CMake changes:

  • Remove all fbjni download/setup code from CMakeLists.txt
  • Remove fbjni from all link libraries
  • No build configuration requires fbjni anymore

JNI changes:

  • Convert jni_layer_training.cpp from fbjni to pure JNI
  • Update TrainingModule.java and SGD.java to use native handles (long) instead of HybridData
  • All JNI layers now use pure JNI with standard JNI calls (GetStaticMethodID, CallStaticObjectMethod, etc.)
  • Replace fbjni-specific classes (HybridClass, JavaClass, local_ref) with manual JNI reference management

All Android builds (including training) no longer depend on fbjni. The entire Android JNI layer is now pure JNI.

Test plan

Verified no Java code imports fbjni. Confirmed soloader usage in Module.java, ExecuTorchRuntime.java, TrainingModule.java, and SGD.java. Reviewed CMake logic to ensure fbjni completely removed. Converted training module C++ code to pure JNI following the pattern used in other JNI layers (jni_layer.cpp, jni_layer_runtime.cpp).


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@pytorch-bot
Copy link

pytorch-bot bot commented Jan 13, 2026

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/16554

Note: Links to docs will display an error until the docs builds have been completed.

❌ 5 New Failures

As of commit 7c41b68 with merge base 3090486 (image):

NEW FAILURES - The following jobs have failed:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jan 13, 2026
Copilot AI changed the title [WIP] Remove fbjni dependencies from build.gradle Remove fbjni dependencies from Gradle and make CMake fbjni conditional Jan 13, 2026
Copilot AI requested a review from kirklandsign January 13, 2026 05:22
# to the version which Android APK links against for runtime to ensure the
# libc++ dependencies are consistent. WARNING # Users need to use the SAME fbjni
# version here and in app gradle dependency for runtime compatibility!
if(NOT FBJNI_VERSION)
Copy link
Contributor

Choose a reason for hiding this comment

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

@copilot We don't need this anymore right?

Copy link
Author

Choose a reason for hiding this comment

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

Correct! The warning about keeping fbjni versions in sync between CMake and Gradle is no longer relevant since we removed the fbjni Gradle dependency. Removed in commit 270e957.

@kirklandsign
Copy link
Contributor

@copilot We don't need code like

  add_custom_command(
    OUTPUT
      "${CMAKE_CURRENT_BINARY_DIR}/third-party/fbjni/prefab/modules/fbjni/include/"
      "${CMAKE_CURRENT_BINARY_DIR}/third-party/fbjni/prefab/modules/fbjni/libs/android.${ANDROID_ABI}/libfbjni.so"
    COMMAND unzip -o ${FBJNI_DOWNLOAD_PATH} -d
            ${CMAKE_CURRENT_BINARY_DIR}/third-party/fbjni
    DEPENDS "${FBJNI_DOWNLOAD_PATH}"
  )

Copy link
Author

Copilot AI commented Jan 13, 2026

@copilot We don't need code like

  add_custom_command(

...

The training module (jni_layer_training.cpp) still uses fbjni headers and classes (HybridClass, local_ref, etc.). If we remove the fbjni download/setup code, the training build will fail.

Should I:

  1. Convert jni_layer_training.cpp to pure JNI (like the other JNI layers), removing fbjni dependency entirely?
  2. Remove training module support completely?
  3. Something else?

@kirklandsign
Copy link
Contributor

@copilot Please Convert jni_layer_training.cpp to pure JNI (like the other JNI layers), removing fbjni dependency entirely

Copy link
Author

Copilot AI commented Jan 13, 2026

@copilot Please Convert jni_layer_training.cpp to pure JNI (like the other JNI layers), removing fbjni dependency entirely

Done! Converted jni_layer_training.cpp to pure JNI and removed all fbjni dependencies.

Changes in commit 7c41b68:

  • Rewrote jni_layer_training.cpp using pure JNI (no more fbjni headers)
  • Updated TrainingModule.java and SGD.java to use native handles (long) instead of HybridData
  • Removed all fbjni download/setup code from CMakeLists.txt
  • Removed fbjni from link libraries

The entire Android JNI layer is now pure JNI with no fbjni dependency.

Copilot AI changed the title Remove fbjni dependencies from Gradle and make CMake fbjni conditional Remove fbjni dependencies completely by converting all JNI layers to pure JNI Jan 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants