hylander0 / iteedee.apkreader Goto Github PK
View Code? Open in Web Editor NEW.NET library written in C# for reading/parsing APK manifest (AndroidManifest.xml) and resource data (Resources.arsc)
.NET library written in C# for reading/parsing APK manifest (AndroidManifest.xml) and resource data (Resources.arsc)
The '.' character, hexadecimal value 0x00, cannot be included in a name. Line 1, position 6.
Hi!, i dont know if this issue have something to do with this Fix, but, i'm still getting this erros with some .apk files(like facebook app, SU, etc) while reading their resources, its in the while loop fixed but, still getting an error:
could you please tell me if i did something wrong. thz
(Sorry for my english.)
Message
The output char buffer is too small to contain the decoded characters, encoding 'Unicode (UTF-8)' >fallback 'System.Text.DecoderReplacementFallback'. Parameter name: chars
ParamName
chars
StackTrace
at Iteedee.ApkReader.ApkReader.extractInfo(XmlDocument manifestXml, Byte[] resources_arsx) in d:\Work\apk parser\Iteedee.ApkReader-master\Iteedee.ApkReader\ApkReader.cs:line 243 at Iteedee.ApkReader.ApkReader.extractInfo(Byte[] manifest_xml, Byte[] resources_arsx) in d:\Work\apk parser\Iteedee.ApkReader-master\Iteedee.ApkReader\ApkReader.cs:line 108 at Windows_Phone_App_Store.Models.ApkStoreDiscover.discover() in d:\Documentos\Visual Studio 2013\Projects\Windows Phone App Store\Windows Phone App Store\Models\apkParser.cs:line 132HelpLink
Source
Iteedee.ApkReader
HResult
-2147024809
Working perfectly but taking 1:30 to 2:00 mints for Apk extraction/response .How to improve the performance/speed?
MyCode
Stream stream = System.IO.File.OpenRead(filePath);
using (ICSharpCode.SharpZipLib.Zip.ZipInputStream zip = new ICSharpCode.SharpZipLib.Zip.ZipInputStream(stream))
{
using (var filestream = new FileStream(filePath, FileMode.Open, FileAccess.Read))
{
ICSharpCode.SharpZipLib.Zip.ZipFile zipfile = new ICSharpCode.SharpZipLib.Zip.ZipFile(filestream);
ICSharpCode.SharpZipLib.Zip.ZipEntry item;
foreach (ICSharpCode.SharpZipLib.Zip.ZipEntry entry in zipfile)
{
if (entry.Name.ToLower() == "androidmanifest.xml")
{
Stream stream1 = zipfile.GetInputStream(entry);
manifestData = new byte[50 * 1024];
stream1.Read(manifestData, 0, manifestData.Length);
}
if (entry.Name.ToLower() == "resources.arsc")
{
Stream stream2 = zipfile.GetInputStream(entry);
BinaryReader binaryReader = new BinaryReader(stream2);
resourcesData = binaryReader.ReadBytes((int)entry.Size);
}
}
}
ApkReader apkReader = new ApkReader();
ApkInfo info = apkReader.extractInfo(manifestData, resourcesData);
model.packageName = string.Format("Package Name: {0}", info.packageName);
model.VersionName = string.Format("Version Name: {0}",info.versionName);
model.VersionCode = string.Format("Version Code: {0}",info.versionCode);
}
Can it retrieve app icons ? Even VectorDrawable and adaptive icons , or combination of both?
Can it retrieve app name?
Hello,
i used this library to parse a lot of APKs. There are two major problem.
First UTF 8 characters in the ressources. The Binary Reader ReadChar() Method is not appropriate for a bunch of APKs. To fix this i used The ReadBytes and System.Encoding Package to parse the Ressources.
Second. The Manifest Parsing fail for Manifests with Text nodes and nested "namespaces".
public static int endDocTag = 0x00100101;
public static int startTag = 0x00100102;
public static int endTag = 0x00100103;
These Tags are not enough. There is a Textnode Tag 0x00100104. And The endDoc Tag may occure multible times. Each endDocTag has a startTag 0x00100100. My workaround is:
else if(tag0 == startDocTag)
{
counter++;
off += 4;
}
else if(tag 0 == endDocTag)
{
if(counter == 0) { break; }
counter --;
off += 4;
}
Now i am able to parse all apks.
It seems that if there are other characters defined between/inside XML tags, parsing breaks, on the account of "unrecognised tag code".
For example, for
>
(probably should be parsed as >
)Just wondering what's your comment on this.
hi,
I have this problem on large files!
I tested this with: instagram last version ( 38MB )
This problem does not exist in small files. Only big files like that
Error Message:
Unhandled Exception: System.Exception: System.IndexOutOfRangeException: Index was outside the bounds of the array.
at Iteedee.ApkReader.APKManifest.LEW(Byte[] arr, Int32 off) in Iteedee.ApkReader\APKManifest.cs:line 248
at Iteedee.ApkReader.APKManifest.ReadManifestFileIntoXml(Byte[] manifestFileData) in Iteedee.ApkReader\APKManifest.cs:line 104
at Iteedee.ApkReader.ApkReader.extractInfo(Byte[] manifest_xml, Byte[] resources_arsx) in Iteedee.ApkReader\ApkReader.cs:line 99
at Iteedee.ApkReader.ApkReader.extractInfo(Byte[] manifest_xml, Byte[] resources_arsx) in Iteedee.ApkReader\ApkReader.cs:line 103
at Iteedee.ApkReader.Run.ReadApk.ReadApkFromPath(String path) in Iteedee.ApkReader.Run\ReadApk.cs:line 49
at Iteedee.ApkReader.Run.Program.Main(String[] args) in Iteedee.ApkReader.Run\Program.cs:line 16
line 248 in "APKManifest.cs":
return (int)(((uint)arr[off + 3]) << 24 & 0xff000000 | ((uint)arr[off + 2]) << 16 & 0xff0000 | ((uint)arr[off + 1]) << 8 & 0xff00 | ((uint)arr[off]) & 0xFF);
in:
public int LEW(byte[] arr, int off)
It would be nice to be able to parse AndroidManifest.xml
only without the need to have resources.arsc
. Currently, I am using APKManifest
and parse the XML by myself, but having the content parsed in the ApkInfo
would be more convenient.
If AndroidManifest file contains cyrilic text (in label) decoded xlm is wrong.
This code works great on my previous apk's!!
but...our android developer brought me a new apk (which was created with android studio 3).
on the new extracted androidmanifest.xml, the function
ReadManifestFileIntoXml(byte[] manifestFileData)
does not work properly. I need greater understanding in reading byte array to understand the failure point accurately, but when I debugged it, I saw that the tags to read the data from no longer match to this new xml.
for example - the:
int tag6 = LEW(manifestFileData, off + 6 * 4); // Expected to be 14001400
is not as the number expected in the comment.
Due to bug in sharpzip, when the apk zipped as deflater mode, the zipinputstream.length is not set until you read the stream out. your example sometimes is not working.
using (Stream strm = zipfile.GetInputStream(item))
{
using (BinaryReader s = new BinaryReader(strm))
{
resourcesData = s.ReadBytes((int)s.BaseStream.Length);
}
}
solution is using entry.size instead of s.BaseStream.Length
using (Stream strm = zipfile.GetInputStream(item))
{
using (BinaryReader s = new BinaryReader(strm))
{
resourcesData = s.ReadBytes((int)item.size);
}
}
@hylander0 how to do ?
One that will work on Android, and that will be able to handle inputStream ?
The reason is that Google plans to ruin storage permission, which means apps won't be able to handle files using File API or file-path.
And yet, the normal Android framework for parsing APK files need a file-path:
There is a lot of talk about it over the Internet, and many are against it, as many libraries, apps, unix commands and even Android's own framework sometimes depend only on file-path and not inputStream.
I have just follow this page.
And while at run-time, I am getting this error. Wrong Local header signature: 0xFF8
My basic aim is to read basic information(like version, logo, name) of .apk file.
Need help ASAP
Currently, the resourceFinder can only handle reference resolve within same type chunk. But a lot of cases, the reference is pointing to another type chunk, current ResourceFinder will return a null value.
I am using "Youtube" apk and when this apk reading using this code it will give exception "Wrong Local header signature: 0x3F8" at line "while((item = zip.GetNextEntry()) != null)". Some apk's are read properly but some apk's are giving these type of exceptions.
Can you please help me for this issue.
It not working with AndroidManifest.xml built by AndroidStudio 3.4.1
It would be nice if you could update the nuget release since the version that is currently published is 9 years old already.
ApkInfo info = apkReader.extractInfo(manifestData, resourcesData);
This error System.Xml.XmlException “Missing root element”
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.