diff --git a/src/main/java/com/reandroid/app/AndroidManifest.java b/src/main/java/com/reandroid/app/AndroidManifest.java index 22b7af02e..b1298891f 100644 --- a/src/main/java/com/reandroid/app/AndroidManifest.java +++ b/src/main/java/com/reandroid/app/AndroidManifest.java @@ -17,6 +17,7 @@ import com.reandroid.utils.ObjectsUtil; +@SuppressWarnings("unused") public interface AndroidManifest { String getPackageName(); @@ -27,8 +28,8 @@ public interface AndroidManifest { void setVersionName(String name); Integer getPlatformBuildVersionCode(); void setPlatformBuildVersionCode(int version); - String getPlatformBuildVersionName(); - void setPlatformBuildVersionName(String name); + Object getPlatformBuildVersionName(); + void setPlatformBuildVersionName(Object name); Integer getCompileSdkVersion(); void setCompileSdkVersion(int version); diff --git a/src/main/java/com/reandroid/arsc/chunk/xml/AndroidManifestBlock.java b/src/main/java/com/reandroid/arsc/chunk/xml/AndroidManifestBlock.java index b0dce26d8..43af4c3da 100644 --- a/src/main/java/com/reandroid/arsc/chunk/xml/AndroidManifestBlock.java +++ b/src/main/java/com/reandroid/arsc/chunk/xml/AndroidManifestBlock.java @@ -30,6 +30,7 @@ import java.util.Iterator; import java.util.List; +@SuppressWarnings("unused") public class AndroidManifestBlock extends ResXmlDocument implements AndroidManifest { private int mGuessedPackageId; public AndroidManifestBlock(){ @@ -408,7 +409,7 @@ public void setPlatformBuildVersionCode(int version){ setManifestAttributeInt(NAME_platformBuildVersionCode, 0, version); } @Override - public String getPlatformBuildVersionName(){ + public Object getPlatformBuildVersionName(){ ResXmlElement manifest = getManifestElement(); if(manifest == null){ return null; @@ -417,11 +418,27 @@ public String getPlatformBuildVersionName(){ if(attribute == null ){ return null; } - return attribute.getValueAsString(); + if(attribute.getValueType() == ValueType.STRING){ + return attribute.getValueAsString(); + } + return attribute.getData(); } @Override - public void setPlatformBuildVersionName(String name){ - setManifestAttributeString(NAME_platformBuildVersionName, 0, name); + public void setPlatformBuildVersionName(Object name){ + Integer versionNumber = null; + if(name instanceof Integer){ + versionNumber = (Integer) name; + }else { + try{ + versionNumber = Integer.parseInt((String) name); + }catch (NumberFormatException ignored){ + } + } + if(versionNumber != null){ + setManifestAttributeInt(NAME_platformBuildVersionName, 0, versionNumber); + }else{ + setManifestAttributeString(NAME_platformBuildVersionName, 0, (String) name); + } } @Override public Integer getMinSdkVersion(){