File: README.md

package info (click to toggle)
golang-github-avast-apkparser 0.0~git20190516.3b8c5ef-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 244 kB
  • sloc: xml: 101; sh: 6; makefile: 2
file content (57 lines) | stat: -rw-r--r-- 1,395 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# apkparser

[![GoDoc](https://godoc.org/github.com/avast/apkparser?status.svg)](https://godoc.org/github.com/avast/apkparser)
[![Build Status](https://travis-ci.org/avast/apkparser.svg?branch=master)](https://travis-ci.org/avast/apkparser)

APK AndroidManifest.xml and resources.arsc parsing.

**Works with Go 1.8 or higher.**

Documentation on [GoDoc](https://godoc.org/github.com/avast/apkparser)

    go get github.com/avast/apkparser

## ZipReader
Because Android can handle even broken ZIP archives, this packages has it's own zip reader,
based on archive/zip.

## axml2xml
A tool to extract AndroidManifest.xml and verify APK signature is also part of this repo.

    go get github.com/avast/apkparser
    go install github.com/avast/apkparser/axml2xml
    ./axml2xml -v application.apk

## Example

```go
package main

import (
	"encoding/xml"
	"fmt"
	"github.com/avast/apkparser"
	"os"
)

func main() {
	enc := xml.NewEncoder(os.Stdout)
	enc.Indent("", "\t")
	zipErr, resErr, manErr := apkparser.ParseApk(os.Args[1], enc)
	if zipErr != nil {
		fmt.Fprintf(os.Stderr, "Failed to open the APK: %s", zipErr.Error())
		os.Exit(1)
		return
	}

	if resErr != nil {
		fmt.Fprintf(os.Stderr, "Failed to parse resources: %s", resErr.Error())
	}
	if manErr != nil {
		fmt.Fprintf(os.Stderr, "Failed to parse AndroidManifest.xml: %s", manErr.Error())
		os.Exit(1)
		return
	}
	fmt.Println()
}
```