diff --git a/jadx-gui/src/main/java/jadx/gui/device/debugger/DbgUtils.java b/jadx-gui/src/main/java/jadx/gui/device/debugger/DbgUtils.java index 620bdbf3a..4915513e7 100644 --- a/jadx-gui/src/main/java/jadx/gui/device/debugger/DbgUtils.java +++ b/jadx-gui/src/main/java/jadx/gui/device/debugger/DbgUtils.java @@ -126,13 +126,21 @@ public class DbgUtils { @Nullable public static JClass searchMainActivity(MainWindow mainWindow) { String content = getManifestContent(mainWindow); - int pos = content.indexOf(" -1) { - pos = content.lastIndexOf(" -1) { - pos = content.indexOf(" android:name=\"", pos); + int pos; // current position + int actionPos = 0; // last found action's index + String actionTag = " -1) { + pos = content.indexOf(actionTag, actionPos + actionTagLen); + actionPos = pos; + int activityPos = content.lastIndexOf(" -1) { + int aliasPos = content.lastIndexOf(" -1 && aliasPos > activityPos; + String classPathAttribute = " android:" + (isAnAlias ? "targetActivity" : "name") + "=\""; + pos = content.indexOf(classPathAttribute, isAnAlias ? aliasPos : activityPos); if (pos > -1) { - pos += " android:name=\"".length(); + pos += classPathAttribute.length(); String classFullName = content.substring(pos, content.indexOf("\"", pos)); // in case the MainActivity class has been renamed before, we need raw name. JavaClass cls = mainWindow.getWrapper().getDecompiler().searchJavaClassByAliasFullName(classFullName); @@ -142,6 +150,9 @@ public class DbgUtils { } } } + if (actionTagLen == 0) { + actionTagLen = actionTag.length(); + } } return null; }