Giter Site home page Giter Site logo

tony19 / apktool-lib Goto Github PK

View Code? Open in Web Editor NEW

This project forked from broo2s/brut.apktool

11.0 6.0 2.0 3.88 MB

A library for decoding XML resources (such as the Android manifest) from an APK

License: Apache License 2.0

Java 92.85% Shell 7.15%
android apk

apktool-lib's Introduction

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

apktool-lib's People

Contributors

arichnad avatar broo2s avatar tony19 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

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.