Skip to content

Commit 3d56fa1

Browse files
committed
try fix aab resource
1 parent 099817c commit 3d56fa1

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

android/src/main/java/cn/reactnative/modules/update/DownloadTask.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,9 +291,16 @@ private void doFullPatch(DownloadTaskParams param) throws IOException {
291291
// e.g., "res/drawable-xxhdpi-v4/img.png" → "res/drawable-xxhdpi/img.png"
292292
private static final Pattern VERSION_QUALIFIER_PATTERN =
293293
Pattern.compile("-v\\d+(?=/)");
294+
// AAB internal paths are prefixed with "base/" (e.g., "base/res/drawable-xxhdpi/img.png")
295+
// which does not exist in standard APK layout
296+
private static final String AAB_BASE_PREFIX = "base/";
294297

295298
private String normalizeResPath(String path) {
296-
return VERSION_QUALIFIER_PATTERN.matcher(path).replaceAll("");
299+
String result = path;
300+
if (result.startsWith(AAB_BASE_PREFIX)) {
301+
result = result.substring(AAB_BASE_PREFIX.length());
302+
}
303+
return VERSION_QUALIFIER_PATTERN.matcher(result).replaceAll("");
297304
}
298305

299306
private String findDrawableFallback(String originalToPath, HashMap<String, String> copiesMap, HashMap<String, ZipEntry> availableEntries, HashMap<String, String> normalizedEntryMap) {

0 commit comments

Comments
 (0)