capacitor-dex-editor 0.0.7 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1306,34 +1306,18 @@ public class DexManager {
1306
1306
  // 解析 DEX 文件
1307
1307
  DexBackedDexFile dexFile = new DexBackedDexFile(Opcodes.getDefault(), dexBytes);
1308
1308
 
1309
- // 收集字符串
1310
- Set<String> uniqueStrings = new HashSet<>();
1311
- int index = 0;
1312
-
1313
- for (ClassDef classDef : dexFile.getClasses()) {
1314
- // 从方法中提取字符串
1315
- for (Method method : classDef.getMethods()) {
1316
- MethodImplementation impl = method.getImplementation();
1317
- if (impl != null) {
1318
- for (Instruction instruction : impl.getInstructions()) {
1319
- String instrStr = instruction.toString();
1320
- // 提取字符串常量
1321
- if (instrStr.contains("\"")) {
1322
- int start = instrStr.indexOf("\"");
1323
- int end = instrStr.lastIndexOf("\"");
1324
- if (start != -1 && end > start) {
1325
- String str = instrStr.substring(start + 1, end);
1326
- if (!uniqueStrings.contains(str)) {
1327
- uniqueStrings.add(str);
1328
- JSObject item = new JSObject();
1329
- item.put("index", index++);
1330
- item.put("value", str);
1331
- strings.put(item);
1332
- }
1333
- }
1334
- }
1335
- }
1336
- }
1309
+ // 直接从 DEX 字符串表中读取所有字符串
1310
+ int stringCount = dexFile.getStringCount();
1311
+ for (int i = 0; i < stringCount; i++) {
1312
+ try {
1313
+ String str = dexFile.getStringSection().get(i);
1314
+ JSObject item = new JSObject();
1315
+ item.put("index", i);
1316
+ item.put("value", str != null ? str : "");
1317
+ strings.put(item);
1318
+ } catch (Exception e) {
1319
+ // 跳过无法读取的字符串
1320
+ Log.w(TAG, "Failed to read string at index " + i, e);
1337
1321
  }
1338
1322
  }
1339
1323
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "capacitor-dex-editor",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "description": "Capacitor-plugin-for-editing-DEX-files-in-APK",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",