fix: gradle export for APKs without strings.xml (PR #2050)

This commit is contained in:
nitram84
2023-12-03 18:38:46 +01:00
committed by GitHub
parent ca03406a3d
commit 1e57e85382
2 changed files with 4 additions and 9 deletions
@@ -55,7 +55,7 @@ public class ExportGradleTask implements Runnable {
.orElseGet(() -> resContainers.stream()
.filter(resContainer -> resContainer.getFileName().contains("strings.xml"))
.findFirst()
.orElseThrow(IllegalStateException::new));
.orElse(null));
ExportGradleProject export = new ExportGradleProject(root, projectDir, androidManifest, strings);
@@ -36,8 +36,6 @@ public class AndroidManifestParser {
this.androidManifest = parseAndroidManifest(androidManifestRes);
this.appStrings = parseAppStrings(appStrings);
validateAttrs();
}
public boolean isManifestFound() {
@@ -60,12 +58,6 @@ public class AndroidManifestParser {
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 @@ public class AndroidManifestParser {
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");