hifromajay / manifestinspector Goto Github PK
View Code? Open in Web Editor NEWA rule-based static analysis tool for detecting developer mistakes in an android manifest file
A rule-based static analysis tool for detecting developer mistakes in an android manifest file
Hi Ajay,
While I am processing a manifest file, I met the exception below:
[Fatal Error] com.android.settings.xml:287:18: The entity name must immediately follow the '&' in the entity reference.
org.xml.sax.SAXParseException; systemId: file:/home/samele/Public/manifest/com.android.settings.xml; lineNumber: 287; columnNumber: 18; The entity name must immediately follow the '&' in the entity reference.
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:257)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:339)
at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:205)
at com.android.manifest.ManifestInspector.getDocument(ManifestInspector.java:37)
at com.android.manifest.ManifestInspector.main(ManifestInspector.java:22)
I followed the exception message and checked the manifest file, which shows like this:
I searched this problem on Stack Overflow, and it seems that before using DOMParser to parse manifest files, we need to change '&' to '&'.
Hope you can fix that.
Hi Ajay,
In ApplicationStructure.java, you used 'elem' at line 119, which might be a null object if the programmer falsely deleted the application tag. Your program will crash and throw NullPointerException at ApplicationStructure.java, line 119. Maybe you could add a null check before this line.
I'm using your program to check some Android Manifest files, and I found that some of them didn't set the minSdkVersion, and your program will be crashed and show these Exceptions:
Exception in thread "main" java.lang.NumberFormatException: For input string: " "
at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:68)
at java.base/java.lang.Integer.parseInt(Integer.java:668)
at java.base/java.lang.Integer.parseInt(Integer.java:776)
at com.android.manifest.AMSecurity.checkExposedProviders(AMSecurity.java:339)
at com.android.manifest.AMSecurity.checkSecurity(AMSecurity.java:36)
at com.android.manifest.ManifestInspector.main(ManifestInspector.java:28)
I assume that you didn't check if minSdkVersion is declared. In the official document of android shows that if minSdkVersion is not declared, it will be assumed as 1. So maybe you should check it.
int minSdk = 0;
if(elem.getAttribute("android:minSdkVersion").equals("")) {
minSdk = 1;
}else {
minSdk = Integer.parseInt(elem.getAttribute("android:minSdkVersion"));
}
I add these code above, and it seems to solve the problem. Maybe this will help you to improve your program.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.