문제

I have to launch an application on android emulator using command line.for that I have knew that there is a method by adb command;

adb shell am start -a android.intent.action.MAIN -n com.example.myApplication

but I have to find the application package name before executing this command, so anybody help me to find the package name, or any alternate solution for running apk on emulator

도움이 되었습니까?

해결책 3

extract the apk file and rebuilt the manifest file, then by parsing the xml manifest file you can find the main activity package name. refer this link for parsing, and refer this link for extracting apk file.

다른 팁

On Linux, simply use this command to get package name:

aapt dump badging {apk-file.apk} | grep package | awk '{print $2}' | sed s/name=//g | sed s/\'//g

Getting main (launcher) activity is similar:

aapt dump badging {apk-file.apk} | grep launchable-activity: | awk '{print $2}' | sed s/name=//g | sed s/\'//g

For my personal usage, I've written a shell script called apkinfo.sh as following:

#!/bin/bash package=`aapt dump badging $* | grep package | awk '{print $2}' | sed s/name=//g | sed s/\'//g` activity=`aapt dump badging $* | grep launchable-activity: | awk '{print $2}' | sed s/name=//g | sed s/\'//g` echo echo package : $package echo activity: $activity

And use it as following:

./apkinfo.sh {path-to-apk-file.apk}

aapt dump badging <path-to-apk>

This is what I use for this in one of my projects, inside a shell script.

apk= #apk path
package=`.//aapt dump badging $apk | grep package | awk '{print $2}' | sed s/name=//g | sed s/\'//g`
echo $package
adb install $apk

if you want to just enter in cmd prompt, then it would be

.//aapt dump badging ***apk relative path*** | grep package | awk '{print $2}' | sed s/name=//g | sed s/\'//g

that should work.

You can use Andgroguard

This is how I did in Python3:

from androguard.misc import AnalyzeAPK
a, d, dx = AnalyzeAPK(apk_file)
package_name = a.get_package()
print(package_name)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top