Giter Site home page Giter Site logo

Comments (1)

AndroidDeveloperLB avatar AndroidDeveloperLB commented on June 1, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.