KeepSafe / ReLinker

A robust native library loader for Android.
Apache License 2.0
3.23k stars 371 forks source link

Unclear MissingLibraryException when IOException occurs during getSupportedABIs() #107

Open MrHadiSatrio opened 6 months ago

MrHadiSatrio commented 6 months ago

Similar to previous reports (#98, #93, and #88), we've encountered MissingLibraryException errors in Production that haven't been reproducible locally. The specific error message is:

Fatal Exception: com.getkeepsafe.relinker.MissingLibraryException: Could not find '<REDACTED>.so'. Looked for: [arm64-v8a, armeabi-v7a, armeabi], but only found: [].

According to the source, there are three scenarios where an empty array might be returned from getSupportedABIs() (whose result is then used to construct the exception):

  1. sourceDirectories(context) returns empty.
  2. IOException occurs during ZipFile initialization.
  3. ZipFile doesn't contain matching library entries.

This report focuses on the second scenario. Currently, the error message doesn't provide any indication that the library might still be present despite the exception. While it wouldn't necessarily help resolve the root cause, a clearer message would reduce ambiguity for those investigating the issue.

Expected

getSupportedABIs() should specify whether or not it was able to look into all available directories without errors in addition to the detected ABIs, for example:

Fatal Exception: com.getkeepsafe.relinker.MissingLibraryException: Could not find '<REDACTED>.so'. Looked for: [arm64-v8a, armeabi-v7a, armeabi], but only found: []. **Error encountered when trying to scan: [<source_dir_1>, <source_dir_2>, <source_dir_n>].**

Actual

Fatal Exception: com.getkeepsafe.relinker.MissingLibraryException: Could not find '<REDACTED>.so'. Looked for: [arm64-v8a, armeabi-v7a, armeabi], but only found: [].