Skip to content

Instantly share code, notes, and snippets.

@huanghantao
Last active June 4, 2019 11:14
Show Gist options
  • Save huanghantao/5abdc5f3152c4e19798db9aff2c715ae to your computer and use it in GitHub Desktop.
Save huanghantao/5abdc5f3152c4e19798db9aff2c715ae to your computer and use it in GitHub Desktop.
解析apk应用包的例子
package main
import (
"flag"
"fmt"
"log"
"github.com/shogo82148/androidbinary/apk"
)
func main() {
fileName := flag.String("filename", "", "pkg filename")
flag.Parse()
pkg, err := apk.OpenFile(*fileName)
if err != nil {
log.Fatal(err)
}
defer pkg.Close()
res := ""
pkgName := pkg.Manifest().Package
res += pkgName
res += "\n"
verCode := pkg.Manifest().VersionCode
verCodeStr := fmt.Sprintf("%d", verCode)
res += verCodeStr
res += "\n"
verName := pkg.Manifest().VersionName
res += verName
res += "\n"
appName, err := pkg.Label(nil)
if err != nil {
log.Fatal(err)
}
res += appName
fmt.Println(res)
}
@huanghantao
Copy link
Author

使用方法:

go run main.go -filename=VehicleGuard_debug.apk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment