Last active
June 4, 2019 11:14
-
-
Save huanghantao/5abdc5f3152c4e19798db9aff2c715ae to your computer and use it in GitHub Desktop.
解析apk应用包的例子
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
使用方法: