Comments (1)
Took me time, but I think I know where it occurs. Just don't know why.
Seems that in BinaryXmlParser.readXmlNodeStartTag , it goes over the attributes of the "manifest" tag to search for "isSplitRequired", but the library actually puts this attribute into the "application" tag instead:
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1511902656" android:versionName="15.14.33" android:compileSdkVersion="29" android:compileSdkVersionCodename="R" package="com.google.android.youtube" platformBuildVersionCode="29" platformBuildVersionName="R">
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="29" />
...
<application android:theme="resourceId:0x7f140408" android:label="YouTube" android:icon="res/CGK.png" android:name="com.google.android.apps.youtube.app.YouTubeApplication" android:backupAgent="com.google.android.apps.youtube.app.application.backup.YouTubeBackupAgent" android:allowBackup="true" android:restoreAnyVersion="true" android:logo="res/d8V.png" android:hardwareAccelerated="true" android:largeHeap="true" android:supportsRtl="true" android:networkSecurityConfig="res/4uC.xml" android:roundIcon="res/C9M.png" android:isSplitRequired="true" android:requestLegacyExternalStorage="true">
For comparison, this is the whole manifest of a split APK file, that I get from the library:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1511902656" configForSplit="" package="com.google.android.youtube" split="config.armeabi_v7a">
<application android:hasCode="false">
<meta-data android:name="com.android.vending.derived.apk.id" android:value="1" />
</application>
</manifest>
Here I can see the "split" attribute in the "manifest" tag.
The parsing is correct : it's supposed to be in the "manifest" tag. But for some reason it didn't get there, but into the "application" tag instead.
Seems there might be other such attributes to moved from one place to another, too.
So, either the parsing need to be flexible and check on both, or that before, there is some bug causing it.
However, if you run these online tools, for example, you will notice that it's going into the "application" tag, too:
https://www.sisik.eu/apk-tool
http://www.javadecompilers.com/
So, for now, a workaround is as such:
switch (xmlNodeStartTag.getName()) {
case "application":
if (apkMetaBuilder.split == null)
apkMetaBuilder.setSplit(attributes.getString("split"));
if (apkMetaBuilder.configForSplit == null)
apkMetaBuilder.setConfigForSplit(attributes.getString("configForSplit"));
if (!apkMetaBuilder.isFeatureSplit)
apkMetaBuilder.setIsFeatureSplit(attributes.getBoolean("isFeatureSplit", false));
if (!apkMetaBuilder.isSplitRequired)
apkMetaBuilder.setIsSplitRequired(attributes.getBoolean("isSplitRequired", false));
if (!apkMetaBuilder.isolatedSplits)
apkMetaBuilder.setIsolatedSplits(attributes.getBoolean("isolatedSplits", false));
...
case "manifest":
apkMetaBuilder.setPackageName(attributes.getString("package"));
apkMetaBuilder.setVersionName(attributes.getString("versionName"));
apkMetaBuilder.setRevisionCode(attributes.getLong("revisionCode"));
apkMetaBuilder.setSharedUserId(attributes.getString("sharedUserId"));
apkMetaBuilder.setSharedUserLabel(attributes.getString("sharedUserLabel"));
if (apkMetaBuilder.split == null)
apkMetaBuilder.setSplit(attributes.getString("split"));
if (apkMetaBuilder.configForSplit == null)
apkMetaBuilder.setConfigForSplit(attributes.getString("configForSplit"));
if (!apkMetaBuilder.isFeatureSplit)
apkMetaBuilder.setIsFeatureSplit(attributes.getBoolean("isFeatureSplit", false));
if (!apkMetaBuilder.isSplitRequired)
apkMetaBuilder.setIsSplitRequired(attributes.getBoolean("isSplitRequired", false));
if (!apkMetaBuilder.isolatedSplits)
apkMetaBuilder.setIsolatedSplits(attributes.getBoolean("isolatedSplits", false));
The reason is that I suspect the split attributes might appear in either of those.
Here's a sample project to test on Android with the workaround :
https://github.com/AndroidDeveloperLB/apk-parser
from apk-parser.
Related Issues (20)
- why bug :Unexpected chunk Type:203? cause:analysis resourse table parser HOT 1
- 解析apk,其中icon是xml格式的,解析出来的字节数组不能解析成png格式使用,有什么办法能解决么
- Bug: gets any XML as AdaptiveIcon for app-icons
- Suggestion: have a look at similar projects
- gets any XML as AdaptiveIcon or foreground is XML ,Data parsing icon cannot be used as png
- 在Android中使用Java库,使用gradle方式。如何使用?
- Bug : unable to get protection level of user-defined permissions
- Request: add a field to tell which kind of APK we have HOT 1
- Request: have sample Android module to use the library
- Bug: library generates invalid manifest XML for APK of Chrome ("com.android.chrome") HOT 1
- Bug: unable to get correct app label/name for some APKs
- Request: ditch bouncycastle dependency
- Bug: crash when trying to parse some APK files HOT 1
- - HOT 1
- Suggestion: here's how you might be able to parse VectorDrawable
- Bug: sometimes can't get any correct app-icon
- signature field of CertificateMeta was removed in v2.6.10 HOT 5
- Bom HOT 1
- 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from apk-parser.