diff --git a/jadx-core/src/main/java/jadx/core/export/TemplateFile.java b/jadx-core/src/main/java/jadx/core/export/TemplateFile.java index 79d56cbe464..5c08cf845db 100644 --- a/jadx-core/src/main/java/jadx/core/export/TemplateFile.java +++ b/jadx-core/src/main/java/jadx/core/export/TemplateFile.java @@ -11,7 +11,6 @@ import java.util.HashMap; import java.util.Map; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import jadx.core.utils.exceptions.JadxRuntimeException; @@ -49,8 +48,8 @@ private TemplateFile(String name, InputStream in) { this.template = in; } - public void add(String name, @NotNull Object value) { - values.put(name, value.toString()); + public void add(String name, @Nullable Object value) { + values.put(name, String.valueOf(value)); } public String build() throws IOException { 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 b9cfeaf6dc8..caa1a59bfa3 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 @@ -66,31 +66,37 @@ private ApplicationParams parseAttributes() { String mainActivity = null; String application = null; + @Nullable Element manifest = (Element) androidManifest.getElementsByTagName("manifest").item(0); + @Nullable Element usesSdk = (Element) androidManifest.getElementsByTagName("uses-sdk").item(0); if (parseAttrs.contains(AppAttribute.APPLICATION_LABEL)) { applicationLabel = getApplicationLabel(); } - if (parseAttrs.contains(AppAttribute.MIN_SDK_VERSION)) { - minSdkVersion = Integer.valueOf(usesSdk.getAttribute("android:minSdkVersion")); - } - if (parseAttrs.contains(AppAttribute.TARGET_SDK_VERSION)) { - String stringTargetSdk = usesSdk.getAttribute("android:targetSdkVersion"); - if (!stringTargetSdk.isEmpty()) { - targetSdkVersion = Integer.valueOf(stringTargetSdk); - } else { - if (minSdkVersion == null) { - minSdkVersion = Integer.valueOf(usesSdk.getAttribute("android:minSdkVersion")); + if (usesSdk != null) { + if (parseAttrs.contains(AppAttribute.MIN_SDK_VERSION)) { + minSdkVersion = Integer.valueOf(usesSdk.getAttribute("android:minSdkVersion")); + } + if (parseAttrs.contains(AppAttribute.TARGET_SDK_VERSION)) { + String stringTargetSdk = usesSdk.getAttribute("android:targetSdkVersion"); + if (!stringTargetSdk.isEmpty()) { + targetSdkVersion = Integer.valueOf(stringTargetSdk); + } else { + if (minSdkVersion == null) { + minSdkVersion = Integer.valueOf(usesSdk.getAttribute("android:minSdkVersion")); + } + targetSdkVersion = minSdkVersion; } - targetSdkVersion = minSdkVersion; } } - if (parseAttrs.contains(AppAttribute.VERSION_CODE)) { - versionCode = Integer.valueOf(manifest.getAttribute("android:versionCode")); - } - if (parseAttrs.contains(AppAttribute.VERSION_NAME)) { - versionName = manifest.getAttribute("android:versionName"); + if (manifest != null) { + if (parseAttrs.contains(AppAttribute.VERSION_CODE)) { + versionCode = Integer.valueOf(manifest.getAttribute("android:versionCode")); + } + if (parseAttrs.contains(AppAttribute.VERSION_NAME)) { + versionName = manifest.getAttribute("android:versionName"); + } } if (parseAttrs.contains(AppAttribute.MAIN_ACTIVITY)) { mainActivity = getMainActivityName();