android apk lib,GitHub - tony19/apktool-lib: A library for decoding XML resources (such as the Andro...

apktool-lib 68747470733a2f2f696d672e736869656c64732e696f2f636972636c6563692f70726f6a6563742f746f6e7931392f61706b746f6f6c2d6c69622f6d61737465722e737667

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值