apktool-lib

"Android XML resource parser"

License

License

GroupId

GroupId

com.github.tony19
ArtifactId

ArtifactId

apktool-lib
Last Version

Last Version

1.4.4-5
Release Date

Release Date

Type

Type

jar
Description

Description

apktool-lib
"Android XML resource parser"
Project URL

Project URL

https://github.com/tony19/apktool-lib
Source Code Management

Source Code Management

https://github.com/tony19/apktool-lib

Download apktool-lib

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.tony19/apktool-lib/ -->
<dependency>
    <groupId>com.github.tony19</groupId>
    <artifactId>apktool-lib</artifactId>
    <version>1.4.4-5</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.tony19/apktool-lib/
implementation 'com.github.tony19:apktool-lib:1.4.4-5'
// https://jarcasting.com/artifacts/com.github.tony19/apktool-lib/
implementation ("com.github.tony19:apktool-lib:1.4.4-5")
'com.github.tony19:apktool-lib:jar:1.4.4-5'
<dependency org="com.github.tony19" name="apktool-lib" rev="1.4.4-5">
  <artifact name="apktool-lib" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.tony19', module='apktool-lib', version='1.4.4-5')
)
libraryDependencies += "com.github.tony19" % "apktool-lib" % "1.4.4-5"
[com.github.tony19/apktool-lib "1.4.4-5"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

apktool-lib CircleCI branch

v1.4.4-5

Overview

This library decodes a given precompiled XML resource (such as AndroidManifest.xml) from an APK without requiring an Android application context.

Normally, precompiled (as opposed to raw) XML can be accessed from an Android application using AssetManager.openXmlResourceParser(). In order to get an instance of AssetManager, the caller must have access to the Android application context, which is normally unavailable for libraries. A possible workaround is to pass the context (e.g., via the consumer's constructor) to libraries that need context-specific classes, but that might be infeasible or undesirable in some applications, including ones that need access to the precompiled XML before the context is initialized. apktool-lib enables libraries to read precompiled XML without an application context or the Android AssetManager.

This is based on the APK Tool project.

Usage

Parse XML events from AXmlResourceParser in a loop, as in the following code example:

import brut.androlib.res.decoder.AXmlResourceParser;

//...

// called from a library, used by an Android application
public void readManifest() {
  InputStream manifestStream = getClassLoader().getResourceAsStream("AndroidManifest.xml");
  parseXmlStream(manifestStream);
}

public void parseXmlStream(InputStream stream) {
  AXmlResourceParser xpp = new AXmlResourceParser(stream);

  int eventType = -1;
  while ((eventType = xpp.next()) > -1) {
    if (XmlPullParser.START_DOCUMENT == eventType) {
      startDocument(xpp);
    } else if (XmlPullParser.END_DOCUMENT == eventType) {
      endDocument();
      break;
    } else if (XmlPullParser.START_TAG == eventType) {
      startElement(xpp);
    } else if (XmlPullParser.END_TAG == eventType) {
      endElement(xpp);
    } else if (XmlPullParser.TEXT == eventType) {
      characters(xpp);
    }
  }
}

Download

Gradle

dependencies {
  compile 'com.github.tony19:apktool-lib:1.4.4-5'
}

Build

Use these commands to create the AAR:

git clone git://github.com/tony19/apktool-lib.git
cd apktool-lib
scripts/makejar.sh

The file is output to: ./build/apktool-lib-1.4.4-5-debug.aar

License

Apache License 2.0

Versions

Version
1.4.4-5
1.4.4-4
1.4.4-3
1.4.4-2
1.4.4-1