Use the backport class loader for extensions before Android 17

ART maps app images compiled for the built-in DelegateLastClassLoader's class loader chain, and before Android 17 a damaged one crashes every launch until the app is updated.
This commit is contained in:
AntsyLich
2026-10-07 19:59:52 +06:00
parent 76b146f3d4
commit 6d4ed6cb22
@@ -13,7 +13,9 @@ fun DelegateLastClassLoaderCompat(
librarySearchPath: String?, librarySearchPath: String?,
parent: ClassLoader, parent: ClassLoader,
): ClassLoader { ): ClassLoader {
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) { // ART recognizes the built-in loader and maps app images compiled for this app's class loader chain, and before
// Android 17 a damaged one crashes every launch until the app is updated. ART doesn't recognize the backport.
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.CINNAMON_BUN) {
DelegateLastClassLoader(dexPath, librarySearchPath, parent) DelegateLastClassLoader(dexPath, librarySearchPath, parent)
} else { } else {
DelegateLastPathClassLoader(dexPath, librarySearchPath, parent) DelegateLastPathClassLoader(dexPath, librarySearchPath, parent)
@@ -21,7 +23,8 @@ fun DelegateLastClassLoaderCompat(
} }
/** /**
* Backport of [DelegateLastClassLoader], which was added in API 27. * A [PathClassLoader] that looks up classes like [DelegateLastClassLoader]: the boot class loader first, then its own
* dex path, then the parent.
*/ */
private class DelegateLastPathClassLoader( private class DelegateLastPathClassLoader(
dexPath: String, dexPath: String,