From 9a0f18525762d19a41e6bada6a83563ebd429aa9 Mon Sep 17 00:00:00 2001 From: nitram84 Date: Sat, 2 Dec 2023 23:48:50 +0100 Subject: [PATCH] fix: gradle export for APKs without strings.xml --- .../main/java/jadx/core/export/ExportGradleTask.java | 2 +- .../core/utils/android/AndroidManifestParser.java | 11 +++-------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/jadx-core/src/main/java/jadx/core/export/ExportGradleTask.java b/jadx-core/src/main/java/jadx/core/export/ExportGradleTask.java index e31753e23b5..72e8e5e45b3 100644 --- a/jadx-core/src/main/java/jadx/core/export/ExportGradleTask.java +++ b/jadx-core/src/main/java/jadx/core/export/ExportGradleTask.java @@ -55,7 +55,7 @@ public void run() { .orElseGet(() -> resContainers.stream() .filter(resContainer -> resContainer.getFileName().contains("strings.xml")) .findFirst() - .orElseThrow(IllegalStateException::new)); + .orElse(null)); ExportGradleProject export = new ExportGradleProject(root, projectDir, androidManifest, strings); diff --git a/jadx-core/src/main/java/jadx/core/utils/android/AndroidManifestParser.java b/jadx-core/src/main/java/jadx/core/utils/android/AndroidManifestParser.java index 8428055b6e4..caaa3e1085c 100644 --- a/jadx-core/src/main/java/jadx/core/utils/android/AndroidManifestParser.java +++ b/jadx-core/src/main/java/jadx/core/utils/android/AndroidManifestParser.java @@ -36,8 +36,6 @@ public AndroidManifestParser(ResourceFile androidManifestRes, ResContainer appSt this.androidManifest = parseAndroidManifest(androidManifestRes); this.appStrings = parseAppStrings(appStrings); - - validateAttrs(); } public boolean isManifestFound() { @@ -60,12 +58,6 @@ public ApplicationParams parse() { return parseAttributes(); } - private void validateAttrs() { - if (parseAttrs.contains(AppAttribute.APPLICATION_LABEL) && appStrings == null) { - throw new IllegalArgumentException("APPLICATION_LABEL attribute requires non null appStrings"); - } - } - private ApplicationParams parseAttributes() { String applicationLabel = null; Integer minSdkVersion = null; @@ -113,6 +105,9 @@ private String getApplicationLabel() { if (application.hasAttribute("android:label")) { String appLabelName = application.getAttribute("android:label"); if (appLabelName.startsWith("@string")) { + if (appStrings == null) { + throw new IllegalArgumentException("APPLICATION_LABEL attribute requires non null appStrings"); + } appLabelName = appLabelName.split("/")[1]; NodeList strings = appStrings.getElementsByTagName("string");